469,915 Members | 2,552 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,915 developers. It's quick & easy.

IsHtmlFile(), IsInternetConnection()

IsHtmlFile(), IsInternetConnection()
====================================
How can I determin with Javascript, wether a Url
("www.123.com/xyz.htm") exists?

How can I determin with Javascript, wether I have Internet connection?
(I want to know this before the Browser Message for dialing up to
Internet is shown)

Thanks Alexander
Jul 20 '05 #1
1 1154
Alexander wrote:
IsHtmlFile(), IsInternetConnection()
====================================

How can I determin with Javascript, wether a Url
("www.123.com/xyz.htm") exists?
Short answer: Client-side JavaScript can not do this.
How can I determin with Javascript, wether I have Internet connection?
(I want to know this before the Browser Message for dialing up to
Internet is shown)


Short answer: Client-side JavaScript can not do this. Even if it could,
when would it run? You are presumably opening your browser to an Internet
page that requires the Operating System to dial. Since the page has not
actually loaded at this point, even if there were a script on that page
that could determine if you are connected to the Internet, it would not
have loaded yet.

Long answer: you can use client-side JavaScript to determine the *success*
of loading an image from a site other then the one you are on, but if it
fails, you have no way of knowing *why* it failed. This is not the same as
knowing if a Web page/site is available or not.

<script type="text/javascript">
var a = new Image();
a.onerror = function() {
alert('Could not load the image, but I have no idea why');
}
a.onload = function() {
alert('Loaded the image');
}
a.src = 'http://somesite/path/to/image.jpg';

--
| Grant Wagner <gw*****@agricoreunited.com>

* Client-side Javascript and Netscape 4 DOM Reference available at:
*
http://devedge.netscape.com/library/...ce/frames.html

* Internet Explorer DOM Reference available at:
*
http://msdn.microsoft.com/workshop/a...ence_entry.asp

* Netscape 6/7 DOM Reference available at:
* http://www.mozilla.org/docs/dom/domref/
* Tips for upgrading JavaScript for Netscape 7 / Mozilla
* http://www.mozilla.org/docs/web-deve...upgrade_2.html
Jul 20 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.

By using this site, you agree to our Privacy Policy and Terms of Use.