By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,717 Members | 1,233 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,717 IT Pros & Developers. It's quick & easy.

Determine online status?

P: n/a
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!
Jul 20 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
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" <ci******@rpgclassics.com> ha scritto nel messaggio
news:77**************************@posting.google.c om...
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!

Jul 20 '05 #2

P: n/a
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. 8-)

--Daniel

"Vicomte De Valmont" <NO****@hotmail.com> wrote in message news:<bn**********@lacerta.tiscalinet.it>...
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" <ci******@rpgclassics.com> ha scritto nel messaggio
news:77**************************@posting.google.c om...
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!

Jul 20 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.