如何判断当前帧是否是父级? [英] How to tell if current frame is parent?
问题描述
直到现在,我试图用
window.parent!= null
但它总是返回false,就像这个简单的例子一样。
< HTML>
< head>
< script>
alert(parent == null);
< / script>
< / head>
< body>
< h1> OH YEAH!< / h1>
< / body>
< / html>
有没有办法做到这一点?我不需要携带,现在我正在寻找IE6解决方案。 非常有用: 总之,如果这段时间太长,那么他们最终会提出这样的建议: 你会在这个pdf中找到许多其他方法来做到这一点, I'm working in a framed environment, and trying to tell if the frame on which some javascript code executes is the top frame (the one that contains the rest). Up until now I was trying to check it with but it always returns false, like in this simple example. Is there a way to do this? I doesn't have to be portable, right now I'm looking for the IE6 solution. I found this pdf to be very useful:
http://seclab.stanford.edu/websec/framebusting/framebust.pdf In short, if this is too long to read, this is what they ultimately propose : You will find many other means to do this in this pdf and each means' pro and cons.
Obviously, on browsers without JavaScript, this solution could be painful ;) 这篇关于如何判断当前帧是否是父级?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
http://seclab.stanford.edu/websec/
< style>
html {display:none; }
< / style>
< script>
if(self == top){
document.documentElement.style.display ='block';
} else {
top.location = self.location;
}
< / script>
显然,在没有JavaScript的浏览器上,这个解决方案可能很痛苦;)window.parent != null
<html>
<head>
<script>
alert(parent == null);
</script>
</head>
<body>
<h1>OH YEAH!</h1>
</body>
</html>
<style>
html { display :none; }
</style>
<script>
if(self==top){
document.documentElement.style.display = 'block';
}else{
top.location=self.location;
}
</script>