我在网站上遇到了很多问题,因为我的 jQuery 由于它在 iFrame 内呈现而导致错误。有什么方法可以告诉我的 jQuery 在 iFrame 内时不要加载?
问问题
382 次
3 回答
1
这应该有效:
window.opener != null
于 2012-06-22T20:23:12.607 回答
1
正如 Greg 在问题评论中的链接中所说,您可以使用 'if(top===self){ outside iframe code here } else { inside iframe code here}' 来执行此操作。
于 2012-06-22T20:29:51.187 回答
1
来自@Greg 的回答
if (top === self) { not in a frame } else { in a frame }
top 和 self 都是窗口对象(以及父窗口),因此您正在查看您的窗口是否是顶部窗口。
于 2012-06-22T20:29:59.347 回答