Advertisement
tahir7us

iFrame Buster Script!

Jul 24th, 2019
361
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.06 KB | None | 0 0
  1. The following script will stop your website from being encased within an iFrame. With the recently social media toolbars that have started to pop up it has become harder and harder to launch successful linkbait campaigns through traffic streams such as Social Media.
  2.  
  3. Digg is the latest culprit when they introduced their Social Media Toolbar, effectively killing linkbait in the process.
  4.  
  5. Basically websites like Digg have the potential of referring thousands upon thousands of visitors to your website if an article or post becomes popular, now what they do is refer that click into an iframe setup where they effectively remain on the Social Media website. The visitor therefore never physically steps foot on your website and no traffic is recorded.
  6.  
  7. Wikipedia have a great article on ‘Framekiller‘ and offers the following scripts to elinimate your website from being encased within an iframe.
  8.  
  9. Place either script with the <head> tags at the top of your web page.
  10.  
  11. <script type="text/javascript">if (top !== self) top.location.replace(self.location.href);</script>
  12.  
  13. Variation that lets the user know why they are being redirected with the use of a pop-up alert:
  14.  
  15. <script type="text/javascript">
  16. if (top !== self) {
  17. alert('The URL '+self.location.href+' cannot be viewed inside a frame. You will be redirected.');
  18. top.location.href = self.location.href;
  19. }
  20. </script>
  21.  
  22. Limitations
  23.  
  24. Because this is a client-side Javascript solution, it relies on the end-user’s browser to enforce their own security. This makes it a beneficial but unreliable means of disallowing your page to be embedded in other pages. The following situations may render the script above useless:
  25.  
  26. The user agent does not support JavaScript.
  27. The user agent supports JavaScript, but this support has been opted out of by the user.
  28. The user agent’s JavaScript support is flawed or partially implemented.
  29. The user agent’s behavior is modified by a virus or plug-in (possibly without the user’s knowledge) in a way that undermines the framekiller script.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement