Determine online status?

D

Daniel Orner

Is it at all possible to use JavaScript to find out if someone's
online or not? E.g. to try and fetch a URL and figure out if it failed
or not? I'm trying to add some functionality to my primarily online
program to also work offline, but I'd need this sort of thing to make
it work well.

Thanks!
 
V

Vicomte De Valmont

Yes, I'm checking again at:
http://www.unitedscripters.com/hotvamps/browsers.html

in IE the navigator object has a property which might be yours:
navigator.onLine
it returns now true - it means that though I'm checking on my local hard
disk this file, actually, it detects my system is online...

If you load the page with NS6 we can find none at least inspecting and
selecting the porpeties and inspecitng a bit the wealth of data. yet, why
not checking if the url protocol is http:? That would posiviely say whether
the user is online, with a marginal error which is not too big (that is:
page loaded online, but disconnection made while reading it)
location.protocol=="http:"
or you can buold an hash array of valid protocols
myprots=[];
myprots["http:"]=1;
myprots["ftp:!]=1; //etc...

then
if(myprots[location.protocol]){/*is ARGUABLY still online*/}

testing it from the location bar by the "javascript:" 'protocol' it gave to
me: "javascript:" :)))

Just an idea, maybe others have better solutions. Just an idea.
ciao
Alberto Vallini
 
D

Daniel Orner

I don't think that would quite work, because I'm more dealing with
seeing if a user is viewing a page from the cache (i.e. offline) or if
he's online. If he is viewing something from the cache, the protocol
will be exactly the same as if he wasn't, if my understanding is
correct.

Anyway... after further thought this might not be the best way of
doing things in any case... but if anyone has any other ideas I'd love
to hear them. :cool:

--Daniel

Vicomte De Valmont said:
Yes, I'm checking again at:
http://www.unitedscripters.com/hotvamps/browsers.html

in IE the navigator object has a property which might be yours:
navigator.onLine
it returns now true - it means that though I'm checking on my local hard
disk this file, actually, it detects my system is online...

If you load the page with NS6 we can find none at least inspecting and
selecting the porpeties and inspecitng a bit the wealth of data. yet, why
not checking if the url protocol is http:? That would posiviely say whether
the user is online, with a marginal error which is not too big (that is:
page loaded online, but disconnection made while reading it)
location.protocol=="http:"
or you can buold an hash array of valid protocols
myprots=[];
myprots["http:"]=1;
myprots["ftp:!]=1; //etc...

then
if(myprots[location.protocol]){/*is ARGUABLY still online*/}

testing it from the location bar by the "javascript:" 'protocol' it gave to
me: "javascript:" :)))

Just an idea, maybe others have better solutions. Just an idea.
ciao
Alberto Vallini



Daniel Orner said:
Is it at all possible to use JavaScript to find out if someone's
online or not? E.g. to try and fetch a URL and figure out if it failed
or not? I'm trying to add some functionality to my primarily online
program to also work offline, but I'd need this sort of thing to make
it work well.

Thanks!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,053
Latest member
BrodieSola

Latest Threads

Top