2012-04-03 82 views
0

我使用JavaScript来判断一个网页是在一个IFRAME:如何判断页面是否在iframe中使用javascript?

if (this != top) { 
    alert("true"); 
} 

enter image description here

,但我得到“真”的时候,即使不是在IFRAME(如电图画),谁也帮我?

+2

[可能感兴趣的一个老问题。(http://stackoverflow.com/questions/958997) – Pointy 2012-04-03 15:19:36

+1

或可能[这](http://stackoverflow.com/questions/ 925039 /检测的iframe嵌入合的JavaScript)。 – 2012-04-03 15:20:48

回答

4

尝试

if (self != top) { 
    alert("true"); 
} 
相关问题