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地址
location.href用法
本文介绍了JavaScript中使用不同对象(如top、self、parent等)进行页面URL跳转的方法,适用于跳出框架或在特定窗口中加载新页面的场景。

被折叠的 条评论
为什么被折叠?



