How to prevent embedding my webpage in iframe?

Possible duplicate:
How to prevent the loading of a page of my site through the frame of a third-party iFrame site

How can I prevent other users from embedding my webpage in an iframe?

+3
source share
2 answers

Another solution:

if (window.top !== window.self) window.top.location.replace(window.self.location.href);
+13
source

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.")
    }
}
+4
source

Source: https://habr.com/ru/post/1755265/


All Articles