Algorithms, Blockchain and Cloud

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.

  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) —

123 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 (AMP Version)

Exit mobile version