Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Autorefresh a page (just once) that is in an IFRAME

Status
Not open for further replies.

Jakobud

Technical User
Mar 9, 2001
51
US
Okay this is sort of a unique challenge maybe...I have a webpage with an IFRAME in it. The contents of the IFRAME are automatically generated every hour from some calendar creation program. So when people visit this webpage, I want the IFRAME contents to automatically refresh just ONCE upon loading (giving them the most upto date calendar immediately). BUT, I cannot put that code in the calendar html file because that html is automatically generated from some other program. So I have to be able to put the code on the parent webpage somehow. Like refreshing the iframe contents with a target name or something. Any ideas?

Jake
 
<iframe id=&quot;frmCalendar&quot;></iframe>
<script>
// this should reload the current page
document.frmCalendar.location.reload();

// this will send it to a specific page
document.frmCalendar.location.href='thispage.htm';
</script> ________________________________________
Michael C Flanakin
Indigo Web Systems
michael.flanakin@indigows.com
 
Okay, now I'm not too good with javascript. I understand what you are doing with this code here. What MY approach to this would be is to do this:

<BODY onLoad=document.frmCalendar.location.reload()>

But the problem with this is that the iframe is defined AFTER the BODY tag...so it doesn't know what frmCalendar is...

So how do I make it reload frmCalendar AFTER it's been defined? Understand what I am asking?

Jakobud
 
That is why I put a script block after the iframe was instantiated. Just doe it the way I mentioned before - that should solve your problem. ________________________________________
Michael C Flanakin
Indigo Web Systems
michael.flanakin@indigows.com
 
Ah okay. Well here check out my code:


<IFRAME id=&quot;frmCalendar&quot; src=calendar/calendar.html width=100% height=588px frameborder=0></IFRAME>

<script>
// this should reload the current page
document.frmCalendar.location.reload();

// this will send it to a specific page
//document.frmCalendar.location.href='thispage.htm';
</script>


And when I view this page in IE, I get this error:

'document.frmCalendar.location' is null or is not an object.

Have any ideas? Thanks for the help by the way.

Jake
 
Ok...this was something I wasn't totally sure about. I just checked the code and here's what you need:

<IFRAME id=&quot;frmCalendar&quot; src=&quot;calendar/calendar.html&quot; width=&quot;100%&quot; height=&quot;588px&quot; frameborder=&quot;0&quot;></IFRAME>

<script>
window.frmCalendar.location.href='Calendar/Calendar.html';
</script>

1. Frames are children of the window, not the document.

2. You cannot use the reload() method on another window.

Hope this helps. I tested the above code and it works. If you want to be able to reload the page without specifying the page again, try this:

<script>
window.frmCalendar.location.href=window.frmCalendar.location.href;
</script> ________________________________________
Michael C Flanakin
Indigo Web Systems
michael.flanakin@indigows.com
 
Unfortunately, this still doesn't work. I don't get an errors or anything, but the page that is in the IFRAME doesn't refresh. The only time it DOES refresh is if I actually click the refresh button on my browser. Then it refreshes the main page AND the page in the IFRAME. But I want the IFRAME page to refresh everytime this page is visited.

Any other thoughts?

Jakobud
 
Post the code you are using. I used this code and it worked with no problems. ________________________________________
Michael C Flanakin
Indigo Web Systems
michael.flanakin@indigows.com
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top