Posted By

ialexs on 02/14/10


Tagged

iframe


Versions (?)

no iframe-ing this page


 / Published in: JavaScript
 

No iframe-ing the page. Found out twitter doing this. Good practice. (You can not iframe any twitter page)

  1. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
  2.  
  3. <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
  4. <head><title>test. no iframe-ing this page</test> </head>
  5.  
  6. <body bgcolor="blue">
  7.  
  8. <script type="text/javascript">
  9. //<![CDATA[
  10. if (window.top !== window.self) {
  11. document.write = "";window.top.location = window.self.location;
  12. setTimeout(function(){document.body.innerHTML='';},1);
  13. window.self.onload=function(evt){document.body.innerHTML='';};
  14. }
  15. //]]>
  16. </script>
  17.  
  18. <h1>this is BLUE<br> <? echo $_SERVER["PHP_SELF"] ?> </H1>
  19.  
  20. </body>
  21. </html>

Report this snippet  

You need to login to post a comment.