2012-06-10 30 views

回答

1

這通常是一個幀斷路器技術。

通常是這樣的:

if(self != top)top.location.href=someUrl; 
+0

可你更詳細的解釋方式,我是新來這個領域? – user496949

0

因爲它有可能把你的頁面的正文中的iframe標籤,您使用top操縱主窗口。請參閱:

主頁

<!--This is the main page--> 
<html> 
    <head> 
     <script> 
     alert(window.top.location.href);//The main page's URL 
     alert(window.self.location.href);//The main page's URL 
     alert(window.top.location.href);//The main page's URL 
     </script> 
    </head> 
    <body> 
     <iframe src="myFrame.html"></iframe> 
    </body> 
</html> 

myFrame.html

<html> 
    <head> 
     <script> 
     alert(window.location.href);//"myFrame.html" 
     alert(window.self.location.href);//"myFrame.html" 
     alert(window.top.location.href);//The main page's URL 
     </script> 
    </head> 
    <body> 
    </body> 
</html> 
相關問題