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 发布
本文介绍了一种通过检测当前窗口是否被嵌套在iframe中来防止内容被恶意利用的安全策略。该方法尝试访问顶层窗口的位置信息以判断当前页面是否正位于iframe内,并采取措施进行防御。
1308

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



