开发者

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

I am using sammy.js in my webpage, and开发者_StackOverflow中文版 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.


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜