Home  >  Article  >  Web Front-end  >  window.top.location的作用_html/css_WEB-ITnose

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

WBOY
WBOYOriginal
2016-06-24 11:26:171240browse

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表示最外面一层。

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn