Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    New Coder
    Join Date
    Dec 2011
    Posts
    15
    Thanks
    2
    Thanked 0 Times in 0 Posts

    JS Timer - directs to next page

    I've got a login page, when you log in another page comes up saying 'you have logged in, continue?'. At the moment you have to click continue to continue on but i want to change that to an automatic redirect after 5seconds.
    Any help would be great.
    loginsession.php REDIRECT to index.php after 5secs is what i'm trying to do.

  • #2
    Supreme Master coder! Philip M's Avatar
    Join Date
    Jun 2002
    Location
    London, England
    Posts
    18,243
    Thanks
    203
    Thanked 2,555 Times in 2,533 Posts
    Code:
    <span id = "message"><span>
    
    <script type = "text/javascript">
    
    document.getElementById("message").innerHTML = "You have logged in successfully and will be automatically redirected to the home page after 5 seconds";
    setTimeout(redir,5000);  // 5 seconds
    
    function redir() {
    window.location.href = "index.php"
    }
    
    </script>

    "A little sincerity is a dangerous thing, and a great deal of it is absolutely fatal". - Oscar Wilde (Irish Poet, Novelist, Dramatist and Critic, 1854-1900)

    All the code given in this post has been tested and is intended to address the question asked.
    Unless stated otherwise it is not just a demonstration.

  • #3
    Supreme Master coder! glenngv's Avatar
    Join Date
    Jun 2002
    Location
    Philippines
    Posts
    11,075
    Thanks
    0
    Thanked 256 Times in 252 Posts
    You can accomplish this without javascript.

    Code:
    <html>
    <head>
    <meta http-equiv="refresh" content="5;url=index.php" />
    </head>
    <body>
    <p>You have logged in successfully. Click <a href="index.php">here</a> to continue.</p>
    </body>
    </html>
    Glenn
    ____________________________________

    My Blog
    Tower of Hanoi Android app (FREE!)
    Tower of Hanoi Leaderboard
    Samegame Facebook App
    vBulletin Plugins
    ____________________________________


  •  

    Posting Permissions

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