/    Sign up×
Community /Pin to ProfileBookmark

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.

to post a comment
JavaScript

9 Comments(s)

Copy linkTweet thisAlerts:
@KorNov 10.2010 — 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.[/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?
Copy linkTweet thisAlerts:
@PNatsumiauthorNov 11.2010 — 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?
Copy linkTweet thisAlerts:
@KorNov 11.2010 — 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?[/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?
Copy linkTweet thisAlerts:
@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). :
Copy linkTweet thisAlerts:
@KorNov 11.2010 — Oh, I see. You need to work offline, probably using HTML5 features, right? ?

See:

http://dev.opera.com/articles/view/offline-applications-html5-appcache/

But I guess You know that, apart IE9beta (and even there with some reserves), no IE browser has implemented HTML5 features
Copy linkTweet thisAlerts:
@PNatsumiauthorNov 11.2010 — Yap.

Thanks for the time Kor.

Best Regards! ?
Copy linkTweet thisAlerts:
@MrRedNov 11.2010 — 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.
Copy linkTweet thisAlerts:
@MrRedNov 11.2010 — 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.
Copy linkTweet thisAlerts:
@KorNov 11.2010 — 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.[/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.
×

Success!

Help @PNatsumi spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 6.17,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @nearjob,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,
)...