Creating script to break web page out of frames.

Issue

Creating script to break web page out of frames.

Solution

Place the below script in the <HEAD></HEAD> section of your HTML.

<script>
<!--
if (top.location != location) { top.location.href = location.href; }
//-->
</script>

Alternatively if you wish to create a link for users to break out of a frame on your website you can add the below example.

<A href="http://www.computerhope.com/" target="_top">Break out of frame</a>

Using either of the above examples will automatically break users out of any frame that links to your page. Keep in mind that some web services such as services that translate your web page into another language may no longer work because of the need of a frame.

Finally, users who have JavaScript disabled will not be taken out of a frame using the first example.

  • Category
  • HTML Q&A
  • Related pages
  • HTML Help
  • Solved?
  • Were you able to locate the answer to your question?