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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

how can I keep a javascript running on webpage when network is down 2

Status
Not open for further replies.

Sverre

Programmer
Feb 16, 2005
33
NO
I have a asp website with some pages depending on clientside javascript. One page is buildt up with an IFRAME. A javascript function is refreshing(downloading) another page inside the IFRAME every 20 sec or so. This works fine, but my as soon as the network drops down the script stops responding. I would like it to continue even if the page is offline so that when the network is up again the content off the IFRAME is refreshed. IS there a way to do this? I am using window.setTimeout in the script to refresh the IFRAME.

---------------------------
There are only 10 types of people in the world. Those who know binary numbers and those who don't
 
Can U post your script to help ?

Water is not bad as long as it stays out human body ;-)
 
The code is something like this:
Code:
<HTML><HEAD>
<Script language=javascript>
function pulliframe()
{
document.all.fra1.src='IPServer.asp';
document.all.fra1.reload();
window.setTimeout('pulliframe()',10000);
}
</script>
</head><Body onload=pulliframe()>
<iframe height=500 width=500 border=0 name=fra1 id=fra1></iframe>
</BODY></HTML>


---------------------------
There are only 10 types of people in the world. Those who know binary numbers and those who don't
 
just a guess but try removing the "document.all.fra1.reload();". when you change the src of the iframe it should automatically reload, and calling the reload function may look for some kind of response from the server
 
Anoter hint : if your script blocks on the reload(), the setTimeout() method will not be called so the new call to pulliframe() will not happen.[sad]

If you replace your setTimeout call inside the method by a window.setInterval('pulliframe()',10000); in the body onload, the task will be repeated indefinitly until you stop it with a stopInterval call.
So, if the reload doesn't block the script engine, your function will be called again even if the network drops.[smile]

Water is not bad as long as it stays out human body ;-)
 
Perhaps you could have a second iframe that attempts to retrieve the page. If it's successful, it will load the page in the iframe the user sees. If it fails (no network connection) it will prevent the page that the user sees from reloading from the server.
 
Thank you WildT and Targol, you are right. :) The reload() call was the problem. I just removed it and it all worked fine. The reason I put it in the first place was when I first testet it I sat on another PC. The script did not reload the page with just document.all.fra1.src='IPServer.asp';
so i testet different things and ended up with the reload() call. It made the thing work on that PC, but now I see that the reason it did not work with only the document.all.fra1.src='IPServer.asp'; was some local problem on that PC (a windows or IE problem maybe?).
Anyway - problem solved. Thank you again!


---------------------------
There are only 10 types of people in the world. Those who know binary numbers and those who don't
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top