1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

setTimeout and firefox

Discussion in 'HTML & Website Design' started by tldmic, Nov 4, 2010.

  1. #1
    Hi guys

    I have been having trouble with this for days now. The code below paused for 2000ms using setTimeout in IE and return to the location specified. It works well in IE but loops forever in Firefox, does any of you know what could be going on, please help

    many thanks
    tldmic

    <script type="text/javascript">
    function validate(form) {
    if(form.subject.value == "") {
    document.write("Please submit!!");
    setTimeout("document.location.href='test.php'",2000);
    return false;
    }
    return true;
    }
    </script>
    <form action='test.php' method='post' onsubmit="return validate(this)">
    <h3 class='post_header'>Message Post:
    </h3>
    <span class='post_title'>
    Message Title : <input type='text' name='subject' size='20'>
    </span>
    <p>
    <input type='submit' name='submit' value="submit">
    </div>
    </form>
     
    tldmic, Nov 4, 2010 IP
  2. krsix

    krsix Peon

    Messages:
    435
    Likes Received:
    11
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Why would you do that? Don't reload your page.
    Just add "Please add a subject" next to the subject input box and .focus() to the message title.
     
    krsix, Nov 4, 2010 IP
  3. tldmic

    tldmic Peon

    Messages:
    41
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Hi,

    thanks very much, I do not know how to do the .focus() thing, can you please advice, thank you again
     
    tldmic, Nov 4, 2010 IP
  4. krsix

    krsix Peon

    Messages:
    435
    Likes Received:
    11
    Best Answers:
    0
    Trophy Points:
    0
    #4
    krsix, Nov 4, 2010 IP
  5. tldmic

    tldmic Peon

    Messages:
    41
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #5
    Hi, thanks a lot, I have made a huge research and discovered that there is bug existing in firefox for setTimeout not to function. I am not yet a guru in programming, but from the internet research, no one was able to give functioning answer.

    I have tried your proposal still nothing happens, what you told me only affects the css or html side not the client side like js.

    however, I have manipulated the results to work in a reverse and it seems to be working,but it's a long process.

    perhaps if you do not mind, provide me with a sample code that works in both IE and FX using setTimeout function.

    Your help does help me a lot to open my eyes to different angle
    :)
    thank you again
     
    tldmic, Nov 4, 2010 IP