faqts : Computers : Programming : Languages : JavaScript

+ Search
Add Entry AlertManage Folder Edit Entry Add page to http://del.icio.us/
Did You Find This Entry Useful?

8 of 20 people (40%) answered Yes
Recently 5 of 10 people (50%) answered Yes

Entry

How can i find using JavaScript whether i am connected across internet or not?

Apr 6th, 2008 18:44
ha mo, Colin Fraser, Siddharth Jain,


I am surprised noone has replied to this particular question before
this, perhaps they all think it is a trick question or something, but
who knows.. Anyway, I am imterpreting this question in two ways, one
being "I know nothing about javascript and want to learn how to use it
so what conditins need exist on my computer to develop scripts?" and "I
have a page but I want to make sure I am connected before I do too much"
The use of Javascript does not depend upon a connection to a server, it
is client-side scripting, which mean it will run whenever the browser is
opened. You can download pages and still use scripts in those pages, as
long as they do not refer to something only found on the server.  You
can write your own scripts and get them to run on your local computer
without any special server based programs. You do not need a compiler,
only a text editor. The only thing you do need is a browser later than
Netscape 2.* or IE 3.0. You may run into some problems with trying to
use recently introduced DOM methods in earlier browsers, or even some of
the fancier code, earlier browsers, particularly IE, were restricted in
what they could  do with Javascripts.
The second part of this answer is even more simple, if you want to test
if your browser is connected, then in your pages just add this code : 
setTimeOut(window.location.reload(), 10000)
It should force a reload from the server, if there is no reload then you
are not connected. The problem here however, is that when other people
use your page they may get a little upset at using a reload when they
were reading something they may consider important.
http://www.businessian.com
http://www.computerstan.com
http://www.financestan.com
http://www.healthstan.com
http://www.internetstan.com
http://www.moneyenews.com
http://www.technologystan.com
http://www.zobab.com
http://www.healthinhealth.com