Solved

remove frame and iframe??

Posted on 2003-11-15
7
516 Views
Last Modified: 2012-06-27
using javascript can anyone please help to make the page come out of IFRAME.
i have the code to come out of the Frame but not from IFRame.

can you please help.

code below helps to come out of frame but not iframe
<SCRIPT LANGUAGE="JavaScript">
<!--
setTimeout ("changePage()", 3000);
function changePage() {
if (self.parent.frames.length != 0)
self.parent.location="default.aspx";
}
// -->
</SCRIPT>
0
Comment
Question by:swech
7 Comments
 
LVL 15

Assisted Solution

by:JakobA
JakobA earned 60 total points
ID: 9757601
<SCRIPT LANGUAGE="JavaScript">
<!--
setTimeout ("changePage()", 3000);
function changePage() {
    if ( top != self ) {   // should work for frames and iframes both.
        top.location="default.aspx";
    }
}
// -->
</script>

regards JakobA
0
 
LVL 25

Expert Comment

by:devic
ID: 9757604
<script>
if (top.location != self.location)
{
      top.location = self.location.href
}
</script>
0
 
LVL 11

Accepted Solution

by:
Zontar earned 50 total points
ID: 9757758
if(top != self)
  top.location.href = self.location.href;

location is an *object*; its href property is the URL string. Setting location doesn't work in some browsers -- set location.href instead.
0
Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 
LVL 15

Expert Comment

by:JakobA
ID: 9757781
>> swech
  Zontar is right. I should have made that correction.
0
 
LVL 10

Expert Comment

by:NetGroove
ID: 9757959
Here my proposal:

<SCRIPT LANGUAGE="JavaScript">
<!--
setTimeout ("changePage()", 3000);
function changePage() {
  if (top.frames.length != 0)
     top.location="default.aspx";
}
// -->
</SCRIPT>

The reason for my variant is that parent can be written when not same domain, but can not be read for the compare.

Good luck,
NetGroove

0
 

Assisted Solution

by:anstp
anstp earned 100 total points
ID: 9760322
here's how i would do it similar to zontar
<script>
if (top.location != self.location)
{
self.location.url="default.aspx"    
top.location = self.location.url
}
</script>
0
 

Author Comment

by:swech
ID: 9760875
Thanks for the  answer.
sorry zontor could not accept you answer coz i'm totally new to javascript so had to do some research on how to redirect to default.aspx. But thanks to anstp for the correct answer.
jokoba's code also worked .

working fine now.,

0

Featured Post

Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

Join & Write a Comment

Suggested Solutions

I've been trying to accomplish this for a while and it just struck me yesterday how to accomplish this task. I have done searches all over the internet looking for ways to email pages from my applications and finally I have done it!!! Every single s…
This article demonstrates how to create a simple responsive confirmation dialog with Ok and Cancel buttons using HTML, CSS, jQuery and Promises
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…

708 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now