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!
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.[/QUOTE] The advance thanks are useless. There is no way to do that only with JavaScript, as JavaScript is a [I]client-side[/I] 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?
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?[/QUOTE] Nope. User has nothing to install, or whichever, but with some conditions:
A direct AJAX request is to be done only [I]within the same domain[/I]. 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?
@PNatsumiauthorNov 11.2010 — #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). :
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.
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.
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.[/QUOTE]
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 [B]onload[/B], 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 [I]we are not talking about onload[/I]. 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 [I]work offline[/I] 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 [I]this[/I] job [I]is[/I] possible, [I]but on using HTML5 and the subsequent JavaScript methods[/I]. See the URL in my previous post.