Solved

Javascript to replace and iframe (brake out)

Posted on 2009-07-13
2
374 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
2 Comments
 
LVL 8

Accepted Solution

by:
Bobaran98 earned 500 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

Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

Question has a verified solution.

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

Suggested Solutions

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…
This article discusses how to create an extensible mechanism for linked drop downs.
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…

805 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