www.webdeveloper.com
Results 1 to 2 of 2

Thread: How to check if a page is available before reloading

Hybrid View

  1. #1
    Join Date
    Oct 2011
    Posts
    3

    How to check if a page is available before reloading

    I have an html page that displays constantly on a monitor up on a wall. The computer that runs the
    browser is in a closet, unattended. Think of it as being like an arrival/departure monitor at the airport.

    It has the following metatag:
    <meta http-equiv='refresh' content='600;url=http://somedomain.com/somepage.htm'>

    which causes the page to reload once every 600 seconds. The html file itself is periodically updated on the server with data changes, by another process which recreates the file and puts it out there in the
    same place with the same name. Works great. Data up on the wall, freshened every 600 seconds.

    The problem is that anything interferes with being able to get the page, which happens very rarely, I
    might get a 404 error or a dns error or whatever. Displaying an error is problematic for this
    application - the image needs to display 24x7 but I don't have a human available to deal with problems
    onsite.

    What I need to do is somehow check to see if the page is available before I attempt to reload it.
    Perfect would be if the reload would check for availability first, then reload the page if it was
    available, but if it wasn't available it would continue to display the old page ... then try again in
    another 600 seconds.

    Any ideas for me?

    Regards,

    Steve Jones

  2. #2
    Join Date
    Mar 2011
    Posts
    1,108
    The easiest solution I can think of would be to replace the <meta> refresh with some JavaScript that would use AJAX to send an HTTP 'HEAD' request for the page. Then if the page was available, the script would reload the page. If not, it would reset the timer and cancel the reload.
    Rick Trethewey
    Rainbo Design

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles