James P.
James P.

Reputation: 19607

Ensure that a page is displayed only in an iframe

I have a page that's been displayed through an iframe as a facebook pagetab. How can I make sure that the page is displayed in an iframe as intended ?

Upvotes: 0

Views: 128

Answers (2)

rationalboss
rationalboss

Reputation: 5389

You cannot always ensure that because your users can always fool the browser that it is what you want it to be. But you can try this:

if (window!=window.top) { /* In a frame! */ }
else { /* probably reload page and redirect to the page embedding the iframe */ }

Upvotes: 1

mplungjan
mplungjan

Reputation: 177692

You mean

if (top==self) location.replace("iframewrapper.html?loc="+escape(location.href))

Upvotes: 3

Related Questions