How can you check if your document is opened in an IFrame?

非 Y 不嫁゛ 提交于 2019-12-18 15:47:09

问题


Is there a way to know if your page is opened inside of an IFrame?

An idea I had was to see if the window object has a .parent property, but this apparently is also true of standalone windows which are opened by Javascript's window.open() function.


回答1:


if (window.top != window.self)
 {
}


来源:https://stackoverflow.com/questions/3918815/how-can-you-check-if-your-document-is-opened-in-an-iframe

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!