From the server is there a way to know that my page is being loaded in an Iframe

只愿长相守 提交于 2019-12-02 07:49:29

问题


I am using sammy.js in my webpage, and if someone uses this webpage in an IFrame (for IE), it will simply redirect the whole page to the location of the IFrame.So, I was thinking if there is a way to check if my page is being requested by an IFrame.If that is the case, then I can simply disable sammy(change lines that play with top.location).

I was thinking that a browser would be sending a few more headers , when a page is loaded in an IFrame.


回答1:


You can do this using javascript with the following code:

if (window!=window.top) { /* I'm in a frame! */ }

To the best of my knowledge, though, there is no way to find this out serverside, as the browser merely sends an http request like it always would. You can try just dumping all of the headers to see if there's any discernible difference, but I really doubt it.



来源:https://stackoverflow.com/questions/4732480/from-the-server-is-there-a-way-to-know-that-my-page-is-being-loaded-in-an-iframe

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