首頁  >  文章  >  web前端  >  window.top.location的作用_html/css_WEB-ITnose

window.top.location的作用_html/css_WEB-ITnose

WBOY
WBOY原創
2016-06-24 11:26:171240瀏覽

top, 表示是顶层页面, 因为页面之中可能嵌入了 frame 等子页面,top表示最外面一层

Html代码

<html>  <head>  <script type="text/javascript">  function breakout()     {     if (window.top!=window.self)        {       window.top.location="/example/hdom/tryjs_breakout.htm"      }     }   </script>  </head>  <body>  <input type="button" onclick="breakout()" value="跳出框架!">  </body>  </html>   

就是你的顶层网页页面的地址对象。 比如现在这个百度知道的页面,它的location.href 就是

http://zhidao.baidu.com/question/88553493.html

而location, 是一个对象,它包括了上面说的那个地址,还有一些方法,

比如replace(替换地址) 等, 和属性 比如 href (地址)

至于top, 表示是顶层页面, 因为页面之中可能嵌入了 frame 等子页面,top表示最外面一层。

陳述:
本文內容由網友自願投稿,版權歸原作者所有。本站不承擔相應的法律責任。如發現涉嫌抄襲或侵權的內容,請聯絡admin@php.cn