?
Solved

Javascript to replace and iframe (brake out)

Posted on 2009-07-13
2
Medium Priority
?
379 Views
Last Modified: 2012-05-07
I have a API call that gets returned into an iframe however I want the page to automatically brake out of the iframe i.e. load new page not inside the iframe but to replace the page with a new one.


0
Comment
Question by:pigmentarts
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 8

Accepted Solution

by:
Bobaran98 earned 2000 total points
ID: 24846024
Here's some JavaScript you can include in the body of any page so that, if the page is opened in any frame that doesn't happen to be the top-most frame, it will break out and replace the top level with itself:

<body>
 
  <!-- html code here, etc. etc. //-->
 
  <script language="javascript1.2">
     var mypage = "index.html"; //replace this with the name of your page
     if(window != top) { top.location.replace(mypage); }
  </script>
 
  <!-- html code here, etc. etc. //-->
 
</body>

Open in new window

0
 
LVL 12

Author Comment

by:pigmentarts
ID: 24847966
perfect!
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction HTML checkboxes provide the perfect way for a web developer to receive client input when the client's options might be none, one or many.  But the PHP code for processing the checkboxes can be confusing at first.  What if a checkbox is…
In this blog, we’ll look at how improvements to Percona XtraDB Cluster improved IST performance.
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

752 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question