Solved

remove frame and iframe??

Posted on 2003-11-15
7
518 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
Efficient way to get backups off site to Azure

This user guide provides instructions on how to deploy and configure both a StoneFly Scale Out NAS Enterprise Cloud Drive virtual machine and Veeam Cloud Connect in the Microsoft Azure Cloud.

 
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

ScreenConnect 6.0 Free Trial

Discover new time-saving features in one game-changing release, ScreenConnect 6.0, based on partner feedback. New features include a redesigned UI, app configurations and chat acknowledgement to improve customer engagement!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
HTTPS jquery doesn't work 9 64
Javasctipt 2 27
Converting dates in JavaScript 2 36
Checking data with javascript 3 19
In this article, we'll look how to sort an Array in JavaScript, including the more advanced techniques of sorting a collection of records either ascending or descending on two or more fields. Basic Sorting of Arrays First, let's look at the …
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…
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…

831 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