Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 Refresh iFrame Parent
Index -> General Programming
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
Warchamp7




PostPosted: Mon Sep 21, 2009 3:58 pm   Post subject: Refresh iFrame Parent

I'm trying to think how to best explain this

I have a webpage with an iframe on it which is a third party site. Now, through the navigation links on this site, it is possible to navigate back to the main page containing the iframe.

Is there some sort of code I can place on the main page so that it will refresh once when visited, thus preventing you from loading the page within itself?


Also if this is better suited for Web Design, my bad.
Sponsor
Sponsor
Sponsor
sponsor
DtY




PostPosted: Mon Sep 21, 2009 4:53 pm   Post subject: RE:Refresh iFrame Parent

I'm confused, this is what I understood,

You have a page with content within an iframe, in that iframe there's a link to the current parent page, so that when you click on it, the main window is a page that contains an iframe, and within that iframe is the current page, which contains an iframe?

I believe that you can use javascript to check the url of a frame (frameref.location like window.location from inside), if the frame location is on the same domain.
Zren




PostPosted: Mon Sep 21, 2009 10:31 pm   Post subject: Re: Refresh iFrame Parent

I think you should look at it like those sites that automatically get rid of any frames when someone uses frames on them (you've probably seen flash games sites do this). They use something like this in Javascript:

Javascript:

<script type="text/javascript">
<!--
if (top.location != self.location) top.location = self.location
// -->
</script>

or

if(parent.location.href!=location.href) top.location.href=location.href;

SRC: http://www.webdeveloper.com/forum/archive/index.php/t-50973.html

The thing is, your locations might be the same (I'm not sure if there will be some sort of OoP on the location), so you might want to check and see if you're "location" is at the top level, in fact, this script might even work by itself. You'll just have to grab out the more important parts for your purpose.

Javascript:

<SCRIPT LANGUAGE="JavaScript">
<!--
setTimeout ("changePage()", 3000);
function changePage() {
if (self.parent.frames.length != 0)
self.parent.location="http://www.bignosebird.com";
}
// -->
</SCRIPT>

SRC: http://bignosebird.com/js/h43.shtml
Warchamp7




PostPosted: Tue Sep 22, 2009 12:17 pm   Post subject: Re: Refresh iFrame Parent

Zren @ Mon Sep 21, 2009 10:31 pm wrote:

Javascript:

<script type="text/javascript">
<!--
if (top.location != self.location) top.location = self.location
// -->
</script>


This seems to be working perfect. Thanks a bunch!
Display posts from previous:   
   Index -> General Programming
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 4 Posts ]
Jump to:   


Style:  
Search: