Thank you for your response and information, jscheuer1. Unfortunately, I can't have it refresh when it's active. There are some pages on this Intranet site that do not load correctly if refreshed. I wouldn't want the script to automatically refresh when I'm working in one of those pages. Some pages of the site are poorly coded, to be honest.
I wish I had seen your post earlier. That's essentially what I had to do, but it only got me started. In IE6, location.reload did not work. It worked fine if the page I was trying to refresh was on my local machine, but it's actually on the Intranet (same error if I used an Internet site, as in my example below). If I tried to reload the Intranet page using location.reload, IE6 errored: "Line 1 Char 1 Error Permission denied Code 0." There's a Microsoft Knowledge Base on this. The solution was basically not to use location.reload.
The index is running from my local machine and the Intranet page loads in the frame. Something else that I had failed to mention was that I was using 2 frames. The top frame is also being loaded from my local machine. We have backups of the particular Intranet site in case one goes down. I use the top frame to just load one of the backups into the bottom frame if necessary. So I realized that whatever page I'm currently using, the script has to be able to know which page to reload and not just keep reloading a broken page.
Before I continue, I want to say that I'm still very much a Javascript beginner, but after a few days of research, I'm getting well acquainted with it and it's actually really fun to work with. Much of the following code has been pulled from difference sources. I wish I could cite them, but in my haste, I never got a chance to bookmark them. I don't know if any of it can be done in a better fashion; I just know that my final product works.
The following example uses location.reload and it would have reloaded any backup page if they were all local pages. 5 second refresh in all examples.
index1.html:
Code:
<html><head>
<script type="text/javascript">
var int=""
function onBlur() {
int=window.setInterval("parent.idm_bottom.location.reload(true);",5000);
};
function onFocus(){
window.clearInterval(int)
int=""
};
</script>
<frameset rows="10,*" border="0" frameborder="0" framespacing="0">
<frame src="idm_top.html" name="idm_top" noresize"/>
<frame src="http://www.yahoo.com/" name="idm_bottom" onblur="onBlur();" onfocus="onFocus();"/>
</frameset>
</head><body></body></html>
idm_top.html (used in index1.html, and index2.html below):
Code:
<html><body>
<a href="http://www.yahoo.com/" target="idm_bottom">Link 1</a> |
<a href="http://www.google.com/" target="idm_bottom">Link 2</a> |
<a href="http://www.bing.com/" target="idm_bottom">Link 3</a> |
</body></html>
The above example gave me the error, so I thought about it a different way. Instead of actually reloading the site, just tell the frame to load a particular page again. This example uses the same idm_top.html above.
index2.html:
Code:
<html><head>
<script type="text/javascript">
var int=""
function onBlur() {
int=window.setInterval("top.frames['idm_bottom'].location.href='http://www.yahoo.com/';",5000);
};
function onFocus(){
window.clearInterval(int)
int=""
};
</script>
<frameset rows="10,*" border="0" frameborder="0" framespacing="0">
<frame src="idm_top.html" name="idm_top" noresize"/>
<frame src="http://www.yahoo.com/" name="idm_bottom" onblur="onBlur();" onfocus="onFocus();"/>
</frameset>
</head><body></body></html>
The problem here is that this will always "reload" only yahoo.com (in this example). If I then wanted to use a backup site (google.com, for example), it would still try to load yahoo.com after 5 seconds onblur. So then I figure I needed to get my idm_top.html involved in this somehow, which leads me to my final working product below, which I'm glad I found soon after:
idm_top.html (used in index3.html):
Code:
<html><body>
<a href="javascript:parent.idm_link('http://www.yahoo.com/');">Link 1</a> |
<a href="javascript:parent.idm_link('http://www.google.com/');">Link 2</a> |
<a href="javascript:parent.idm_link('http://www.bing.com/');">Link 3</a> |
</body></html>
index3.html, which works for my particular set of needs:
Code:
<html><head>
<script type="text/javascript">
var int=""
var idmbot="http://www.yahoo.com/"
function idm_link(url) {
idmbot=url;
top.frames['idm_bottom'].location.href=idmbot;
}
function onBlur() {
int=window.setInterval("top.frames['idm_bottom'].location.href=idmbot;",5000);
};
function onFocus(){
window.clearInterval(int)
int=""
};
</script>
<frameset rows="10,*" border="0" frameborder="0" framespacing="0">
<frame src="idm_top.html" name="idm_top" noresize"/>
<frame src="http://www.yahoo.com/" name="idm_bottom" onblur="onBlur();" onfocus="onFocus();"/>
</frameset>
</head><body></body></html>
Thank you for reading. I'm not sure if anyone will find any of this useful, I certainly had fun on this small project and wanted to share my progress.
Bookmarks