refresh page

Discussion in 'JavaScript' started by hostydotnet, Feb 26, 2008.

  1. #1
    Hey everyone,

    I'm sorry about the seemingly simple question, but I can't for the life of me (and three other people) see what the problem is....

    Here's my basic test HTML page (test.html):

    <html>
    <head>
    <meta http-equiv="Refresh" content="5;url=test.html">
    <script>
    var cur = 5;
    function start() {
    cur--;
    window.setTimeout("start();", 1000);
    document.getElementById("test").innerHTML = cur;
    }
    </script>
    </head>
    <body onload="start();"><span id="test"></span></body>
    </html>

    As you can see, it's got a basic countdown that gets displayed and the page should refresh after 5 seconds

    What my question has to with is the META tag.

    The refresh works fine in Firefox but does nothing when I try it in Internet Explorer...

    Is there something blatantly wrong here or am I just losing it?

    Thanks so much for your replies
     
    hostydotnet, Feb 26, 2008 IP
  2. LogicFlux

    LogicFlux Peon

    Messages:
    2,925
    Likes Received:
    102
    Best Answers:
    0
    Trophy Points:
    0
    #2
    I think the url in url={url} needs to be an absolute path.
     
    LogicFlux, Feb 26, 2008 IP
  3. vpguy

    vpguy Guest

    Messages:
    275
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    0
    #3
    It's also possible that your IE is setup to disallow Meta refreshes.

    Go into Tools > Internet Options > Security > Custom Level.

    Scroll down to the Miscellaneous header, and in there should be the choice called "Allow META REFRESH", which can be either Enabled or Disabled. You may want to check that it's not set to Disabled.

    ...and if that's the case, the same could happen to visitors of your site, so you may want to avoid using Meta Refresh altogether and change your code to look like this:

    
    <html>
    <head>
    <script>
    var cur = 5;
    function start() 
    {
        cur--;
        if (cur >= 0)
        {
            window.setTimeout("start();", 1000);
            document.getElementById("test").innerHTML = cur;
        }
        else
        {
            location.href = "test.html";
        }
    }
    </script>
    </head>
    <body onload="start();"><span id="test"></span></body>
    </html>
    
    Code (markup):
     
    vpguy, Feb 29, 2008 IP