【html】使ifram搭建的项目,新页面跳出框架


方法一:
<a href="<?php echo $baseUrl . '#/study/order';?>" target="_parent">新页面</a>
 
方法二:
 
top.location.href=”url”          在顶层页面打开url(跳出框架)

扩展:

top.location.href=”url”          在顶层页面打开url(跳出框架)  

self.location.href=”url”         仅在本页面打开url地址  

parent.location.href=”url”      在父窗口打开Url地址   

this.location.href=”url”       用法和self的用法一致     

if (top.location == self.location) 
判断当前location 是否为顶层来 禁止frame引用   
如果页面当中有自定义的frame的话,也可以将parent  self   top换为自定义frame的名称      效果就是在自定义frame窗口打开url地址

实际中可能这样使用

 if(top !== self){             
    top.location.href = location.href;        
 }   //禁止frame引用

ps:

top表示主窗口,location表示当前窗口,如果你的文件只有一个框架,没有iframe和frmaeset,那么是完全一致的,没有区别。

top.location是在顶层frame中打开新页   window.location是在当前frame中打开新页
parent.location 在当前窗口的父窗口打开Url地址
 
top表示主窗口,location表示当前窗口,如果你的文件只有一个框架,没有iframe和frmaeset,那么是完全一致的,没有区别。

 

 

 

 

参考链接:https://www.cnblogs.com/hlws/p/5943141.html

 

 

 

 

 

 

作者:smile.轉角

QQ:493177502

 


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM