一聚教程网:一个值得你收藏的教程网站

最新下载

热门教程

防止页面被iframe调用的代码

时间:2015-03-20 编辑:简简单单 来源:一聚教程网

在我写的一个应用中,出现了iframe重叠的情况,现记录解决方案如下:(登录页的时候出现了重叠)


if(self != top){
    // 强制跳转到top
    top.location = self.location.href;
}

再介绍一点。判断一个页面是否在iframe中

self != top

调用iframe层的父层方法可以用

parent.method()

得到iframe父层元素

$(window.parent.document).find("#demo")

热门栏目