IsHtmlFile(), IsInternetConnection()

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Alexander

    IsHtmlFile(), IsInternetConnection()

    IsHtmlFile(), IsInternetConne ction()
    =============== =============== ======


    How can I determin with Javascript, wether a Url
    ("www.123.co m/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
  • Grant Wagner

    #2
    Re: IsHtmlFile(), IsInternetConne ction()

    Alexander wrote:
    [color=blue]
    > IsHtmlFile(), IsInternetConne ction()
    > =============== =============== ======
    >
    > How can I determin with Javascript, wether a Url
    > ("www.123.co m/xyz.htm") exists?[/color]

    Short answer: Client-side JavaScript can not do this.
    [color=blue]
    > 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)[/color]

    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 <gwagner@agrico reunited.com>

    * Client-side Javascript and Netscape 4 DOM Reference available at:
    *


    * Internet Explorer DOM Reference available at:
    *
    Gain technical skills through documentation and training, earn certifications and connect with the community


    * 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


    Comment

    Working...