如何阻止iframe里引入的html自动跳转


问题:  在页面中用iframe引入别的页面链接,但它会跳转到这个引入的链接上

原因:引入的html中有  if (top.location != self.location) {top.location=self.location;}    使用这段代码后,会自动判断当前的location是否是顶层的,即是否被嵌套到iframe里面了,如果是,则强制跳转。

解决:

1、