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 5 of 5
  1. #1
    New to the CF scene
    Join Date
    Apr 2009
    Posts
    3
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Question How do i hide a <div> after a delay?

    I'm wondering if someone could help me out with a script that hides a <div> a couple of seconds after the page is loaded. I have little to no experience in Java, so i'm not sure how to go about it.
    Last edited by Zyprexa; 04-14-2009 at 06:10 PM.

  • #2
    Master Coder
    Join Date
    Dec 2007
    Posts
    6,682
    Thanks
    436
    Thanked 890 Times in 879 Posts
    Quote Originally Posted by Zyprexa View Post
    I'm wondering if someone could help me out with a script that hides a <div> a couple of seconds after the page is loaded. I have little to no experience in Java, so i'm not sure how to go about it.
    java or javascript? if is java then you post in the wrong forum.

    with javascript you can do something like that:
    Code:
    function hideit(){
      var o = document.getElemenById('tohide');
      o.style.display = 'none';
    }
    window.onload = function(){
      setTimeout("hideit()",5000); // 5 seconds after user (re)load the page
    };
    in html you must have:
    Code:
    <div id="tohide">
    ......
    </div>
    not tested,

    best regards

  • #3
    New to the CF scene
    Join Date
    Apr 2009
    Posts
    3
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Could not get it to work

    Could not get this to work

    This is the code i tested:

    Code:
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>Untitled Document</title>
    <script type="text/javascript">
    function hideit(){
      var o = document.getElemenById('hidethisone');
      o.style.display = 'none';
    }
    window.onload = function(){
      setTimeout("hideit()",5000); // 5 seconds after user (re)load the page
    };
    </script>
    
    </head>
    
    <body>
    <div id="hidethisone">
    THIS SHOULD VANISH
    </div>
    </body>
    </html>

  • #4
    Master Coder
    Join Date
    Dec 2007
    Posts
    6,682
    Thanks
    436
    Thanked 890 Times in 879 Posts
    Quote Originally Posted by Zyprexa View Post
    Could not get this to work

    This is the code i tested:

    Code:
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>Untitled Document</title>
    <script type="text/javascript">
    function hideit(){
      var o = document.getElemenById('hidethisone');
      o.style.display = 'none';
    }
    window.onload = function(){
      setTimeout("hideit()",5000); // 5 seconds after user (re)load the page
    };
    </script>
    
    </head>
    
    <body>
    <div id="hidethisone">
    THIS SHOULD VANISH
    </div>
    </body>
    </html>
    typo, missing a 't':
    Code:
      var o = document.getElementById('hidethisone');
    best regards

  • Users who have thanked oesxyl for this post:

    Zyprexa (04-14-2009)

  • #5
    New to the CF scene
    Join Date
    Apr 2009
    Posts
    3
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Thumbs up solved

    Worked like a charm!

    Thanks alot!


  •  

    Tags for this Thread

    Posting Permissions

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