Velocity Reviews

Velocity Reviews (http://www.velocityreviews.com/forums/index.php)
-   Javascript (http://www.velocityreviews.com/forums/f68-javascript.html)
-   -   Detecting presence of Internet connection (http://www.velocityreviews.com/forums/t921014-detecting-presence-of-internet-connection.html)

Peter Flynn 10-27-2005 09:38 PM

Detecting presence of Internet connection
 
I'm having trouble finding example code to detect the presence of
an Internet connection. It doesn't seem to be a very frequently
asked question, as all I need is the answer yes or no (is the user
connected or not). I'm not interested in speed detection or any
other aspect of the connection, just its existence or not. The
reason is to be able to intercept link clicks on a CD-based set
of HTML pages and pop up a warning if there is no connection;
otherwise pass the request through to the net.

///Peter


Ivan Marsh 10-27-2005 09:44 PM

Re: Detecting presence of Internet connection
 
On Thu, 27 Oct 2005 22:38:47 +0100, Peter Flynn wrote:

> I'm having trouble finding example code to detect the presence of an
> Internet connection. It doesn't seem to be a very frequently asked
> question, as all I need is the answer yes or no (is the user connected
> or not). I'm not interested in speed detection or any other aspect of
> the connection, just its existence or not. The reason is to be able to
> intercept link clicks on a CD-based set of HTML pages and pop up a
> warning if there is no connection; otherwise pass the request through to
> the net.


How would you intend to determine between having an IP address on a LAN
and having a connection on to the internet without pinging an address on
the internet?

The easiest way is to ask the user: Do you have a connection to the
internet?

--
The U.S. Government today announced that it is changing its emblem from an
Eagle to a CONDOM because it more accurately reflects the government's
political stance... A condom allows for inflation, halts production, destroys
the next generation, protects a bunch of pricks, and gives you a sense of
security while you're being screwed.


Peter Flynn 10-27-2005 10:40 PM

Re: Detecting presence of Internet connection
 
Ivan Marsh wrote:

> On Thu, 27 Oct 2005 22:38:47 +0100, Peter Flynn wrote:
>
>> I'm having trouble finding example code to detect the presence of an
>> Internet connection. It doesn't seem to be a very frequently asked
>> question, as all I need is the answer yes or no (is the user connected
>> or not). I'm not interested in speed detection or any other aspect of
>> the connection, just its existence or not. The reason is to be able to
>> intercept link clicks on a CD-based set of HTML pages and pop up a
>> warning if there is no connection; otherwise pass the request through to
>> the net.

>
> How would you intend to determine between having an IP address on a LAN
> and having a connection on to the internet without pinging an address on
> the internet?


For the specific application the users involved either have Internet
access or they are offline completely (eg using a laptop out of range
of wireless, phone, etc), so the state of being on the LAN but without
Internet access won't arise (fortunately).

> The easiest way is to ask the user: Do you have a connection to the
> internet?


The publisher is against this...

///Peter

RobG 10-28-2005 12:00 AM

Re: Detecting presence of Internet connection
 
Peter Flynn wrote:
> I'm having trouble finding example code to detect the presence of
> an Internet connection. It doesn't seem to be a very frequently
> asked question, as all I need is the answer yes or no (is the user
> connected or not). I'm not interested in speed detection or any
> other aspect of the connection, just its existence or not. The
> reason is to be able to intercept link clicks on a CD-based set
> of HTML pages and pop up a warning if there is no connection;
> otherwise pass the request through to the net.
>
> ///Peter


I think your real requirement is to detect if a particular resource is
avaialble or not - whether the user has access to the internet or not
is moot. Access to the URI could be blocked for any number of reasons
unrelated to general internet access. Resources may be in different
domains; some local, others not.

There are detailed instruction at the link below, with code, to detect
whether the user can access a particular URI. Create a 'can my
function access this URI' function based on the code provided and you
will have a much more robust function that doesn't care about how or
whether the user is connected to internet:

<URL:http://www.xml.com/pub/a/2005/02/09/xml-http-request.html>


--
Rob



All times are GMT. The time now is 03:49 AM.

Powered by vBulletin®. Copyright ©2000 - 2014, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.