如何判断当前页面是否在iframe中

通过如下代码:

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
if(window!=window.top)
{
alert("在iframe中");
}
if(window!=window.top) { alert("在iframe中"); }
if(window!=window.top)
{
   alert("在iframe中");
}

或:

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
if(self!=top)
{
alert("在iframe中");
}
if(self!=top) { alert("在iframe中"); }
if(self!=top)
{
   alert("在iframe中");
}

© 版权声明
THE END
喜欢就支持一下吧
点赞0 分享