|
|||||||
![]() |
|
|
Thread Tools | Search this Thread |
|
#1
|
|||
|
|||
|
I'm working on a site that is going to be loading external pages into a frame. These are going to be both text and graphics that update as quick as 5 minutes. My question is how do I get the frame to refresh itself and whatever content is currently displayed?
I'm not good on javascript, but I was playing with a script I found that is pretty much this (in the frameset index.htm page): Code:
setTimeout('refresh()', 300000);
function refresh() {
window.frames['main'].location.replace();
setTimeout('refresh()', 300000);
Thanks! |
|
#2
|
||||
|
||||
|
Put the location url for the content:
Code:
setTimeout('refresh()', 300000);
function refresh() {
window.frames['main'].location.replace('here');
setTimeout('refresh()', 300000);
Code:
window.frames['main'].location.replace('somepage.htm');
__________________
WWWWWWWWWWWW - John________________________ Really Show Your Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate |
|
#3
|
|||
|
|||
|
Right, but is there a way to make it load whatever is in that window? It's going to have numerous (probably around 20ish) pages and I'm trying to get a script on the index.htm frameset page that will refresh that frame not matter what is in it. Can I point the refresh to the name of the frame instead of a URL?
Thanks! |
|
#4
|
|||
|
|||
|
...or somehow make it read the url that is loaded in that frame. The images and text are going to be coming from an external source, and they range from .gif to .txt and the 'main' frame itself doesn't always load a .html file, sometimes it just loads a .gif or .txt. Hope that makes sense.
|
|
#5
|
||||
|
||||
|
You can give this a shot, worked here in local testing:
Code:
function refresh() {
window.frames['main'].window.location.replace(window.frames['main'].window.location);
setTimeout('refresh()', 300000);
}
setTimeout('refresh()', 300000);
Code:
window.frames['main'].window.location.replace(here);
__________________
WWWWWWWWWWWW - John________________________ Really Show Your Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate |
|
#6
|
|||
|
|||
|
Thanks! I'm gonna give that a try in a few minutes. I haven't put the site up yet (just starting it), but if that doesn't work, I'll post it.
In short, there's 3 frames: top, side, main Top links to side, side links to main Side is composed of links to pages or images (ie. http://www.whatever.com/page.htm or http://www.whatever.com/image.gif), that load into the main frame and those pages/images are on an external server (not tied in with me). Those images are updated in 5-10min intervals and I'm trying to get my site to refresh them (by refreshing the frame itself, since I'm going to have a lot of links to manage). I'll let you know here in a bit if that code works. |
|
#7
|
|||
|
|||
|
Okay, doesn't seem it worked. I uploaded the site:
http://www.towpc.com/ke5ehi/wx/ I've put a graphic for the 'main' window that updates every 10 minutes, and I've changed the refresh timer to 25 seconds (for testing). Give it a looksy and see what might be wrong when you got a minute. My goal, again, is for anything loaded in the 'main' window to be refreshed every 5 minutes. If I can tack on a script on each link for another script to refresh it, that would work too (as long as it doesn't try to refresh the last page with the script and when a page is loaded that doesn't need to be refreshed, it refreshes it back to the last refreshable item). I'm getting tired of typing 'refresh', heh |
|
#8
|
|||
|
|||
|
Wait a sec... it worked when I reloaded the page and the main.htm was in the main window, but it doesn't work when a graphic or page (ie SPC Main Page) is loaded.
|
|
#9
|
||||
|
||||
|
That has to do with the security of a frame's content across domains. You didn't mention before (as far as I remember) that this would be off site content. My idea of keeping track of the URL works here though. The way to do that would be something like so:
Code:
<!-- Refresh 'main' window, 5min -->
<script type="text/javascript">
//Set theURL to the initial page for 'main'
var resetVar, theURL="http://www.srh.noaa.gov/radar/images/DS.p19r0/SI.kinx/latest.gif";
function refresh() {
window.frames['main'].window.location.replace(theURL);
resetVar=setTimeout('refresh()', 60*1000*5);
}
function reset(url){
if (typeof url!=='undefined')
theURL=url
clearTimeout(resetVar)
resetVar=setTimeout('refresh()', 60*1000*5);
}
reset();
</script>
HTML Code:
<a href="info.htm" onclick="parent.window.reset(this.href);return true;" target="main">Page Info</a> HTML Code:
<a href="info.htm" onclick="parent.window.reset();return true;" target="main">Page Info</a>
__________________
WWWWWWWWWWWW - John________________________ Really Show Your Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate |
|
#10
|
|||
|
|||
|
Thanks John, you rock! That's working except one issue. I've uploaded the site again (most of the links at the top don't work yet) so you can see.
I've set the timer to 20 seconds for testing. When the site loads, the main page will refresh after 20 seconds. If you click on SPC Products from the menu, then click anything else in the SPC menu, it will reload the 'main.htm' after 20 seconds. I put the link code on the link under "Watch, Warning, Adv." named SPC: "Watches." When you click that link, it will load the watches image (http://www.spc.noaa.gov/products/watch/validww.png) and will reload that image every 20 seconds. But if you click say SPC: "WWA", after 20 seconds it will reload the 'Watches' graphic. How do I keep it so when a link is clicked that doesn't have the refresh onclick code, it won't reload the last image that was set to refresh? I hope this is making some sense. Most of the images that are loaded (ie http://www.spc.noaa.gov/products/watch/validww.png) need to be refreshed in 5 min intervals, but some of the pages (ie http://www.spc.noaa.gov) that are loaded into the main frame have their own refresh code on the page, so I don't have to make them refresh myself. Thanks again for the help, I'll make sure to mention ya in the credits. |
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
|
|