It depends on what that script is doing. Give us more details.
All the script does is to load a web page which contains data from an SQL database. The script is split into two parts, I have the parent which displays header text and graphics and also has an iFrame which is refreshed ever 30 seconds. The iFrame calls the child which display the data from the database.
Its that simple. The problem I am having is every now and then the internet connection is lost and when this happens the iFrame displays the message "Internet connection lost" or words to that effect.
I must thanks you so much for your time in writing your script.
It appears to work fine. The only issue I have is when the connection is lost I get an alert on screen which requires user action. Is there any way to stop the alert from displaying and just let the script run.
(function ( img, wait, notify )
var iObj = new Image();
iObj.onerror = function()
if( notify )
alert( 'reloading' );
location.reload( true );
iObj.onload = function()
setTimeout( test, wait );
iObj.src = img + '?t=' + new Date();
})( 'images/myimage.gif', 2000, false );
// 'myimage.gif' = URL of a small image present on your server
// 2000 = milliseconds between tests
// true/false = display confirmation alert before reload
With the ( 'images/myimage.gif', 2000, false ); set to false and I run the script in my browser and then disable my connection the whole page stops and IE says "Internet Explorer cannot display the webpage".
If I set it to true I get an alert which requires user action. I think Logic Ali has the right approach but I just need to get a result without an alert popping up.
Again, many thanks for any assistance you can provide.
There are now 4 parameters. The second is the ID of the target iframe. Instead of alerting when the last parameter is set to true, messages appear in the title bar instead (document must have a <title> set).
Where used, return should be executed unconditionally and always as the last statement in the function.
That's my signature, it's not part of the damn post!