3

Possible Duplicate:
How to prevent my site page to be loaded via 3rd party site frame of iFrame

How can I prevent others from embedding my web page inside an iframe?

Community
  • 1
  • 1
user389055
  • 251
  • 2
  • 6
  • 13

2 Answers2

13

Another solution:

if (window.top !== window.self) window.top.location.replace(window.self.location.href);
robjmills
  • 18,129
  • 15
  • 73
  • 119
4

With Javascript:

if(window.top==window){
    // not in iframe/frame
} else {
    if(parent.parent.someFunction){
       parent.parent.someFunction();
    } else {
       alert("parent.parent.someFunction() not defined.")
    }
}
fabrik
  • 13,717
  • 8
  • 55
  • 70
  • Up-voted. Although I would re-direct to the actual web page in the else statement rather than throw a scary-looking alert message to the end user, whom may not understand what's going on. – Martin Bean Jul 19 '10 at 08:21
  • @Martin: Of course this one is an example. He can do anything in the statement. – fabrik Jul 19 '10 at 13:15