neeraja
neeraja

Reputation: 140

Javascript: How to check the existence of a url?

I need to check the whether an external url like http://www.example.com exists or not using javascript or ajax.

Thanks in advance..

Upvotes: 3

Views: 193

Answers (1)

T.J. Crowder
T.J. Crowder

Reputation: 1075427

You can load it into a hidden iframe and see if you get content. You can't use "ajax" (e.g., an XMLHttpRequest call) for it, because you'll run into Same Origin Policy restrictions.

Upvotes: 3

Related Questions