[JavaScript] 2段防止被人iframe的代码 →→→→→进入此内容的聊天室

来自 , 2020-10-08, 写在 JavaScript, 查看 183 次.
URL http://www.code666.cn/view/baeabb8f
  1. <script>
  2.  
  3. // Break out of an iframe, if someone shoves your site
  4. // into one of those silly top-bar URL shortener things.
  5. //
  6. // Passing `this` and re-aliasing as `window` ensures
  7. // that the window object hasn't been overwritten.
  8. //
  9. // Example:
  10. //   var window = 'haha, punked!';
  11. //
  12. // Note: Probably unnecessary, but just for kicks.
  13.  
  14. (function(window) {
  15.   if (window.location !== window.top.location) {
  16.     window.top.location = window.location;
  17.   }
  18. })(this);
  19.  
  20. </script>
  21.  
  22.  
  23.  
  24. //javascript/4109

回复 "2段防止被人iframe的代码"

这儿你可以回复上面这条便签

captcha