window.top.location的作用

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

Html代码 
  1. <html>  
  2. <head>  
  3. <script type="text/javascript">  
  4. function breakout()   
  5.   {   
  6.   if (window.top!=window.self)    
  7.     {   
  8.     window.top.location="/example/hdom/tryjs_breakout.htm"  
  9.     }   
  10.   }   
  11. </script>  
  12. </head>  
  13. <body>  
  14.   
  15. <input type="button" onclick="breakout()" value="跳出框架!">  
  16.   
  17. </body>  
  18. </html>    

 就是你的顶层网页页面的地址对象。
比如现在这个百度知道的页面,它的location.href 就是
http://zhidao.baidu.com/question/88553493.html

而location, 是一个对象,它包括了上面说的那个地址,还有一些方法,
比如replace(替换地址) 等, 和属性 比如 href (地址)

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

posted on 2011-10-09 11:20  草原和大树  阅读(24660)  评论(0编辑  收藏  举报