Entry
How can I Validate an URL in javascript? Not just the syntax but that it is a valid http URL
Apr 7th, 2008 22:53
ha mo, Sheana blogs, Colin Fraser, Monisha,
This is a very difficult question to answer as it implies alot of
different things.
Javascript can be used to make sure that a URL is properly formed, that
is that it has no characters in it that are outside the range of
characters used in URLS. The string handling capabilties of Javascript
are clearly noted elsewhere in FAQTS and it can be easy to validate a
URL.
However, you are not asking for validation, you are asking for
verification, and that can be done in one of two ways.
1. Ask the user to verify that that is the website they want to go to
2. Go to the site without asking the user anything.
These two solutions seem to be somewhat redundant however, in terms of
the question asked.
The only other possible solution that may present itself is to ask the
site if it exists by a simple ping. For that, though, I am not sure
that even server-side Javascript will do it. I know that PHP has that
capability, it has a existing function that will detect broken links
and report them, unfortunately, that functionality may only be
available in a CMS like Post-Nuke. (I just don't know enough about PHP
to answer this, but there is a PHP FAQTS page, so look there.)
Having said that, I am not sure what it is you are trying to achieve
here. If you are creating links to URLs then it is encumbent upon you,
as the author of a site, to ensure the links are current, it is part of
the normal housekeeping duties of a Webmaster. How you do that is
entirely up to you. Good luck, and I am sorry I did not have a better
answer for you.
http://islandsofworld.blogspot.com/
http://worldsbestbeaches.blogspot.com/
http://top-honeymoondestinations.blogspot.com/
http://topweddingguide.blogspot.com/
http://webdesigningarticles.blogspot.com/
http://hairlossarticles.blogspot.com/
http://www.businessian.com
http://www.computerstan.com
http://www.financestan.com
http://www.healthstan.com
http://www.internetstan.com
http://www.moneyenews.com
http://www.technologystan.com
http://www.zobab.com
http://www.healthinhealth.com