Verifying a link \ url using javascript.

P

Pete

Hi,


Is there a way to detect the existence of one web page from another?

Basically to verify that a link in a web page is valid.

Similar to the idea of an "ONLINE \ OFFLINE" monitor?

I am not a programmer but just wondered if possible and a basic how
to?

Pete
 
T

Tony

I have not tried this myself, but it sounds possible, although a bit
complicated. First, you create a hidden <iframe> on the page. Then, use
JavaScript to load a URL into that iframe. You can then access the
loaded iframe after a delay to see if a something besides a 404 page
was loaded. This solution definitely isn't for beginners.
 
M

Martin Honnen

Pete wrote:

Is there a way to detect the existence of one web page from another?

Basically to verify that a link in a web page is valid.

Similar to the idea of an "ONLINE \ OFFLINE" monitor?

I am not a programmer but just wondered if possible and a basic how
to?

You could use an image on the server e.g.
<img src="http://example.com/testimage.gif"
onerror="this.src = 'error.gif';">

While you can do a HTTP request in some browsers like IE5/6 on Win or
Mozilla so that you in theory could do a HTTP HEAD request for instance
and check the HTTP response status code the problem is that you can
usually only make requests to the server your page has been loaded from.

Of course if you use script outside the browser for instance in an ASP
page those restrictions do not apply and you can do HTTP requests and
check URLs or even load them.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,777
Messages
2,569,604
Members
45,227
Latest member
Daniella65

Latest Threads

Top