I have a website: galiro.com/summer.html I want to redirect people who use my website in an iframe to the actual website. Is this possible?
Asked
Active
Viewed 110 times
-3
-
1Algorithm is: -> Check if the window and parent window are same. -> If they are, do nothing. -> If they aren't, change parent window address and start again. – hjpotter92 Jul 15 '12 at 21:48
-
possible duplicate of [Prevent iframe stealing](http://stackoverflow.com/questions/5522097/prevent-iframe-stealing) – Zeta Jul 15 '12 at 21:49
1 Answers
4
This should do it:
if (window.top != window.self) {
window.top.location.href = "http://galiro.com/summer.html";
}

Esailija
- 138,174
- 23
- 272
- 326

Elliot Bonneville
- 51,872
- 23
- 96
- 123
-
1Isn't this an infinite loop? You just keep redirecting the iframe and the condition will be true all the time. – Esailija Jul 15 '12 at 21:52
-
1
-
1