Javascript Function To Jump Out Of The Frame


Some unfriendly websites may link your pages but put yours under one of the iframes. This is annoying and may compromise the user experience.

You can avoid this by using a tiny Javascript function that will automatically detect such situations. If this does occur, the current page will jump out of the iframe.

1
2
3
4
5
6
7
8
9
  function jumpoutofframe()
  {
    if (window.top != window.self)
    {
      window.top.location = window.self.location;
    }
  }
 
  windows.onload = jumpoutofframe;
  function jumpoutofframe()
  {
    if (window.top != window.self)
    {
      window.top.location = window.self.location;
    }
  }

  windows.onload = jumpoutofframe;

If the top URL is not the current URL (in the frame), then replace the TOP location with the current page. Simple but effective.

–EOF (The Ultimate Computing & Technology Blog) —

GD Star Rating
loading...
140 words
Last Post: How to Create a Ranking Page in WordPress Based On GD Star Rating Plugin?
Next Post: How to Get the list of emails from the WordPress Comments?

The Permanent URL is: Javascript Function To Jump Out Of The Frame

One Response

  1. Xoxo

Leave a Reply