if (window.top !== window.self) { // are you trying to put self in an iframe?
try {
if (window.top.location.host) { // this is illegal to access unless you share a non-spoofable document domain
// fun times
} else {
bust(); // chrome executes this
}
} catch (ex) {
bust(); // everyone executes this
}
}
js 判断是当前页是否在框架的最顶层
最新推荐文章于 2025-03-21 15:03:08 发布
本文介绍了一种使用JavaScript来检测当前网页是否被嵌套在iframe中的方法。通过检查window.top与window.self的关系,可以有效地判断并采取相应措施防止内容被不当嵌套。

1280

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



