隨筆-9  評論-2  文章-0  trackbacks-0
          "window.location.href"、"location.href"是本頁面跳轉(zhuǎn).
          "parent.location.href" 是上一層頁面跳轉(zhuǎn).
          "top.location.href" 是最外層的頁面跳轉(zhuǎn).
          舉例說明:
              如果A,B,C,D都是html,D是C的iframe,C是B的iframe,B是A的iframe,如果D中js這樣寫
              "window.location.href"、"location.href":D頁面跳轉(zhuǎn)
              "parent.location.href":C頁面跳轉(zhuǎn)
              "top.location.href":A頁面跳轉(zhuǎn)
          如果D頁面中有form的話,
              <form>:  form提交后D頁面跳轉(zhuǎn)
              <form target="_blank">:  form提交后彈出新頁面
              <form target="_parent">:  form提交后C頁面跳轉(zhuǎn)
              <form target="_top"> :  form提交后A頁面跳轉(zhuǎn)

          如果訪問的是iframe里面的頁面,重新加載最外層的頁面
          <html>
          <head>
          <title></title>
          <script language="javascript">
          function escapeFrame(){
                
          if (window.top.location.href != window.location.href) {
                  window.top.location.reload();
                }
          }
          </script>
          </head>

          <body onload="escapeFrame()">
          <iframe src="b.html" ></iframe>
          </body>
          </html>
          posted on 2011-06-28 10:25 secret_x15 閱讀(5495) 評論(1)  編輯  收藏 所屬分類: js

          評論:
          # re: 關(guān)于js中window.location.href,location.href,parent.location.href,top.location.href的用法 2016-08-17 15:58 | 11
          323  回復  更多評論
            

          只有注冊用戶登錄后才能發(fā)表評論。


          網(wǎng)站導航:
           
          主站蜘蛛池模板: 仪征市| 新郑市| 建平县| 海安县| 济宁市| 扬州市| 山西省| 庄河市| 武鸣县| 开封市| 综艺| 巴青县| 裕民县| 长春市| 云和县| 旬邑县| 崇信县| 云梦县| 古蔺县| 宜宾市| 乐至县| 岑溪市| 瑞昌市| 大冶市| 旌德县| 惠东县| 惠安县| 六安市| 赞皇县| 吉隆县| 莲花县| 甘孜| 商河县| 五寨县| 新化县| 交城县| 临澧县| 堆龙德庆县| 新兴县| 科技| 曲沃县|