Tom*_*Tom 5 html javascript frames internet-explorer-6
我在一个框架环境中工作,并试图判断一些javascript代码执行的框架是顶框架(包含其余部分的框架).
到目前为止,我试图检查它
window.parent != null
Run Code Online (Sandbox Code Playgroud)
但它总是返回false,就像在这个简单的例子中一样.
<html>
<head>
<script>
alert(parent == null);
</script>
</head>
<body>
<h1>OH YEAH!</h1>
</body>
</html>
Run Code Online (Sandbox Code Playgroud)
有没有办法做到这一点?我不需要便携,现在我正在寻找IE6解决方案.
我发现这个pdf非常有用:http: //seclab.stanford.edu/websec/framebusting/framebust.pdf
简而言之,如果这个问题太长而无法阅读,那么这就是他们最终提出的建议:
<style>
html { display :none; }
</style>
<script>
if(self==top){
document.documentElement.style.display = 'block';
}else{
top.location=self.location;
}
</script>
Run Code Online (Sandbox Code Playgroud)
在这个pdf中你会发现许多其他方法可以做到这一点,每个都意味着'赞成和反对.显然,在没有JavaScript的浏览器上,这个解决方案可能很痛苦;)
归档时间: |
|
查看次数: |
3364 次 |
最近记录: |