How to stop iframe, frame thefts of our site resources.
Sites like Google Image search , goodphptutorials.com and phpcamp.net displays the website under the IFRAME .No one want their site to be displayed it under the IFRAME, FRAMES. If you want to protect your site to be displayed under the IFRAME,FRAMES then just copy and paste below javascript code after body tag.
1 2 3 4 5 6 | if (window.top !== window.self) { document.write = ""; window.top.location = window.self.location; setTimeout(function(){document.body.innerHTML='';},1); window.self.onload=function(evt){ document.body.innerHTML='';}; } |
Here we use simple logic that we check our page document window is main window or not. if our document isn’t in main window it might be in iframe or frame. then we switch the location of main window to our existing document locations. Before doing this redirection we make the document empty, because the imposter can break this code before loading .

