判断是否在iframe中,页面跳出iframe访问。

1、方式一

if(self.frameElement && self.frameElement.tagName == 'IFRAME'){

  top.window.location.replace(url);//如果是在iframe中直接让父元素跳出iframe。

}

2、方式二

if(window.frames.length != parent.frames.length){

  top.window.location.replace(url);

}

3、方式三

if(self != top){

  top.window.location.replace(url);

}

posted @ 2018-04-23 10:18  镜镜哒  阅读(1336)  评论(0编辑  收藏  举报