views:

113

answers:

2

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?

+2  A: 

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
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
ok thanks..it works.....
@Martin: Of course this one is an example. He can do anything in the statement.
fabrik
+4  A: 

Another solution:

if (window.top !== window.self) window.top.location.replace(window.self.location.href);
seengee
+1 for conciseness and only using in-built functions
Cez