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!

event.returnValue does not work 1

Status
Not open for further replies.

blasuis

Programmer
May 4, 2007
1
BE
Problem:
* "window.event.returnValue=x" >> does not work at every place in the code.
* "window.event.returnValue=false;" >> Works always fine when it is NOT inside the "e.onerror = function()" or inside the e.onload = function()"

Q: why it is working fine when the "event.returnValue=false;" is placed inside the "OnClickDone() but does not work when it is placed inside the e.onerror/e.onload functions?

The code with explanation of the problem:

function OnClickDone()
{
var i = 0;
var e = document.createElement("img");//try to load img
e.src = "e.onerror = function()//can't load, so return event false.
{
window.event.returnValue=false;//does not work >>(the next page should not be loaded)
alert("OFF Line");//works fine
e = null;
};
e.onload = function()
{
window.event.returnValue=true;// it passes here, but does not do it.
alert("ON Line");//work fine
e = null;
};

Thanks,
 
While I don't kow the answer to your question, I think I can help you out with what you're trying to achieve (a connection status test).

I wrote one of these a long while ago, based on my FAQ faq216-5781, but never got around to posting it.

I've added it to the FAQ section now, as I can remember at least 3 other people asking for one of these.

faq216-6639

Hope this helps,
Dan

Coedit Limited - Delivering standards compliant, accessible web solutions

[tt]Dan's Page [blue]@[/blue] Code Couch
[/tt]
 
Dan, just curious.. couldn't the image get cached on the client and cause a false "Online" status? Also, I see Internet Explorer has a navigator.onLine status you can query - though I don't know which version started including this. Does FireFox have something like this?

Adam
 
>couldn't the image get cached on the client and cause a false "Online" status?

That's what happened when I tested it.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top