dcsimg
www.webdeveloper.com
Results 1 to 10 of 10

Thread: url checker

  1. #1
    Join Date
    Nov 2010
    Posts
    4

    Unhappy url checker

    Hi there.
    I've got a problem! I'm trying to create a simple html page, with javascript (NO AJAX!, etc,... ) on it, to let me know if an url (remote file) is online or not.
    I can't find an solution!

    Thanks in advance.

  2. #2
    Join Date
    Dec 2003
    Location
    Bucharest, ROMANIA
    Posts
    15,428
    Quote Originally Posted by PNatsumi View Post
    Hi there.
    I've got a problem! I'm trying to create a simple html page, with javascript (NO AJAX!, etc,... ) on it, to let me know if an url (remote file) is online or not.
    I can't find an solution!

    Thanks in advance.
    The advance thanks are useless. There is no way to do that only with JavaScript, as JavaScript is a client-side language. It runs only at the client's level, and can not touch the server (nor everything outside the browser). Simple as that.

    What bothers you to use AJAX? It is not a fancy technique, and it is merely based on JavaScript, except the special object request. Do you know how AJAX works?
    Last edited by Kor; 11-10-2010 at 01:39 PM.

  3. #3
    Join Date
    Nov 2010
    Posts
    4

    reply: url checker

    Tks Kor.

    I never used AJAX. Is it necessary for the user in client-side to have any thing installed? Or it can run normaly/independent like javascript?

  4. #4
    Join Date
    Dec 2003
    Location
    Bucharest, ROMANIA
    Posts
    15,428
    Quote Originally Posted by PNatsumi View Post
    Tks Kor.

    I never used AJAX. Is it necessary for the user in client-side to have any thing installed? Or it can run normaly/independent like javascript?
    Nope. User has nothing to install, or whichever, but with some conditions:

    A direct AJAX request is to be done only within the same domain. Otherwise you need also a proxy code, written in a server-side language, where AJAX will send the request. And, of course, the document which makes the AJAX request must be put on a server. OR, it might run locally, but only if the user installs a Web Server on his computer, as Apache or IIS

    Which is your situation? Where from do you want to check the existence of that URL. Locally? Or from a server? If on server, is that URL belonging to the same domain or not?

  5. #5
    Join Date
    Nov 2010
    Posts
    4

    reply

    That's the problem... i want to run the htlm file locally. This html returns the status(exists/don't exists) of the server file (www.myserver.com/file.any).
    This html file can not be online, it must be localy in the client (whitout the need of installing any server software). :\

  6. #6
    Join Date
    Dec 2003
    Location
    Bucharest, ROMANIA
    Posts
    15,428
    Oh, I see. You need to work offline, probably using HTML5 features, right?

    See:
    http://dev.opera.com/articles/view/o...tml5-appcache/

    But I guess You know that, apart IE9beta (and even there with some reserves), no IE browser has implemented HTML5 features

  7. #7
    Join Date
    Nov 2010
    Posts
    4

    reply

    Yap.
    Thanks for the time Kor.

    Best Regards!

  8. #8
    Join Date
    Feb 2009
    Location
    UK
    Posts
    142

    Wink

    Hmm let me see

    onLoad - now wouldn't that report a success in loading any page? Though curiously it does not wait for rendering to finish (in my not so humble experience).
    If you want to look at the contents - sorry - unless the page is on your domain it is not possible. Broken links would probably report succcessful loading! But onLoad should tell you it has loaded. And you can proceed with other JavaScript functions/code.

    I am always amazed when I see the word "NO!"

    I believe in the words "Try this" - if they don't produce results it has made the tryer think and look and think again. This is a community after all.

    "NO!" never made anything.

  9. #9
    Join Date
    Feb 2009
    Location
    UK
    Posts
    142
    http://www.javascriptkit.com/howto/htaccess2.shtml
    says something about "page not found" "not loaded" type errors.
    You can set-up your own error page (don't know how just yet) on your own domain. In which case a failure to read a page would display your page on your domain and thus could be read (try body.innerHTML) and the contents would tell you something - especially if you could set-up several pages, one for each error that could be trapped.

    Have a go.

    I would load the desired page into a FRAME or IFRAME (give it a name &/or id) and write the inspection code in the designated onLoad function.

  10. #10
    Join Date
    Dec 2003
    Location
    Bucharest, ROMANIA
    Posts
    15,428
    Quote Originally Posted by MrRed View Post
    Hmm let me see

    onLoad - now wouldn't that report a success in loading any page? Though curiously it does not wait for rendering to finish (in my not so humble experience).
    If you want to look at the contents - sorry - unless the page is on your domain it is not possible. Broken links would probably report succcessful loading! But onLoad should tell you it has loaded. And you can proceed with other JavaScript functions/code.

    I am always amazed when I see the word "NO!"

    I believe in the words "Try this" - if they don't produce results it has made the tryer think and look and think again. This is a community after all.

    "NO!" never made anything.
    It's a matter of how one puts a question. A well structured, clear and correct question will bring a well structured, clear and correct answer. Should have the OP made it clear from the beginning that he wants to know how works the Working Offline feature, the answer would not have been NO

    Regarding the onload, I must tell you that, even in theory onload could be applied on all the tags, in practice it works selectively, according to the browser.

    But here we are not talking about onload. You are barking at the wrong tree . In fact the OP does not want to open a document and, within that document, to check if another url exists. He wants to work offline at will: that means - if the machine (computer, smartphone, iPad, etc) is connected to the Internet and if a certain url can be connected, the user should work online. If not, should work offline, based on the data stored previously at the first successful connection. Now this job is possible, but on using HTML5 and the subsequent JavaScript methods. See the URL in my previous post.
    Last edited by Kor; 11-11-2010 at 06:39 AM.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles