我已经尝试了许多window属性,来确定一个iframe页面是否能够知道它自己被嵌入到了一个iframe中。我尝试过以下属性:
if(top.location!= self.location) //doesn't work in Google Chrome
alert("I am in an iframe!")
以下内容在所有浏览器上都可以运行,但在Chrome上不起作用。我正在为Firefox和Chrome编写用户脚本,但是Chrome真的不太好处理。有没有办法判断Chrome是否能检测到它所在的页面在iframe中?