Verifying a link \ url using javascript.

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Pete

    #1

    Verifying a link \ url using javascript.


    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
  • Tony

    #2
    Re: Verifying a link \ url using javascript.

    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.

    Comment

    • Martin Honnen

      #3
      Re: Verifying a link \ url using javascript.



      Pete wrote:

      [color=blue]
      > 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?[/color]

      You could use an image on the server e.g.
      <img src="http://example.com/testimage.gif"
      onerror="this.s rc = '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.

      --

      Martin Honnen
      http://JavaScript.FAQTs.com/

      Comment

      Working...