SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    orange pips! orange pips!
    Join Date
    Oct 2001
    Location
    Its all about location
    Posts
    652
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Redirecting using timeout and history.back

    I'm wanting to set a timeout for a page using the setTimeout function. I'm also wanting to send the user back to the page they were just at when the timer is hit. I've been using the following code:

    Code:
    <script language='javascript'>
       onload = function() 
       { 
          setTimeout(history.back(-1), 5000);
       }
    </script>
    When the page that contains this code is opened, it immediately takes the user back to the page they just viewed without waiting the 5 seconds. Can anyone tell me what I'm doing wrong?

  2. #2
    SitePoint Wizard silver trophy
    Join Date
    May 2003
    Posts
    1,843
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Can anyone tell me what I'm doing wrong?
    Well...frankly, the whole idea.

    <script type="text/javascript">

    onload = function()
    {
    setTimeout('history.go(-1)', 5000);
    }
    </script>
    ::: certified wild guess :::

  3. #3
    orange pips! orange pips!
    Join Date
    Oct 2001
    Location
    Its all about location
    Posts
    652
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Ah, it would be the single quotes that I missed. Thank you!


Bookmarks

Posting Permissions

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