SitePoint Sponsor

User Tag List

Results 1 to 22 of 22

Hybrid View

  1. #1
    SitePoint Enthusiast
    Join Date
    Aug 2004
    Location
    Lisbon
    Posts
    36
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Timeout and redirect

    I trying to get a DIV to show up, after the timeout disappear, and when it disappears, the user gets redirected to another page. I need the redirection to page to be setup on the DIV HTML line. The script can be called from there to.
    This is what I have. It is a collection of ideas from different authors:

    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
    <html>
    <head>
    <meta http-equiv="content-type" content="text/html; charset=windows-1250">
    <meta name="generator" content="PSPad editor, www.pspad.com">
    <title></title>

    <script type="text/javascript">

    $('#msg').ready(function () {
    setTimeout(function () {
    $('#msg').hide();
    window.location.href = 'index.php';
    }, 3000);
    });

    </script>

    <style>
    .hide {
    display:none;
    }

    .show {
    display:block;
    }
    /* Information-Success */
    .infobox{
    position: absolute;
    top:50%;
    bottom: 0;
    margin-left: 30%;
    margin-right: 30%;
    width: 40%;
    height:50px;
    padding-top: 5px;
    border:solid 1px #008800;
    background:#D5FFC6;
    color:#48A41C;
    font-family:Arial, Helvetica, sans-serif;
    font-size:14px;
    font-weight:normal;
    text-align:center;
    }

    /* Error */
    .errorbox{
    position: absolute;
    top:50%;
    bottom: 0;
    margin-left: 30%;
    margin-right: 30%;
    width: 40%;
    height:50px;
    padding-top: 5px;
    border:solid 1px #880000;
    background:#FDE4E1;
    color:#CB4721;
    font-family:Arial, Helvetica, sans-serif;
    font-size:14px;
    font-weight:normal;
    text-align:center;
    }
    </style>

    </head>
    <body>
    <div id="msg" class = "infobox">You have selected The Info Box</div>
    </body>
    </html>

    Right now the way it is, is not hiding and not redirecting. Can someone help?

    Thank You

  2. #2
    Community Advisor bronze trophy
    fretburner's Avatar
    Join Date
    Apr 2013
    Location
    Brazil
    Posts
    1,441
    Mentioned
    45 Post(s)
    Tagged
    13 Thread(s)
    You need to include jquery before your JS code
    HTML Code:
    <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>

  3. #3
    SitePoint Enthusiast
    Join Date
    Aug 2004
    Location
    Lisbon
    Posts
    36
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thank You I did it, and now is timing out and redirecting. Now, how can I include the page to redirect to on the DIV tag?

  4. #4
    Community Advisor bronze trophy
    fretburner's Avatar
    Join Date
    Apr 2013
    Location
    Brazil
    Posts
    1,441
    Mentioned
    45 Post(s)
    Tagged
    13 Thread(s)
    You mean add a HTML link inside the div? Something like this:
    HTML Code:
    <a href="index.php">Link text here</a>

  5. #5
    SitePoint Enthusiast
    Join Date
    Aug 2004
    Location
    Lisbon
    Posts
    36
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I mean change the index.php in the script to what ever I need at the DIV loading

  6. #6
    Community Advisor bronze trophy
    fretburner's Avatar
    Join Date
    Apr 2013
    Location
    Brazil
    Posts
    1,441
    Mentioned
    45 Post(s)
    Tagged
    13 Thread(s)
    Change this line here:
    Code JavaScript:
    window.location.href = 'index.php';


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
  •