Results 1 to 6 of 6

Thread: On bodyload settimeout for hiding floating overlay

  1. #1
    Join Date
    Feb 2010
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default On bodyload settimeout for hiding floating overlay

    Hi there,

    I hope someone can help me. I want to have insert a JS settimeout to automatically load/action the onclick close button function (in red) after 7 seconds of the page loading. Ive coded the action into a button but im not sure how to translate it into a timed event as well.

    Code:
    <html> 
    <head> 
    <meta http-equiv="Content-Type" content="text/html; charset=windows-1250"> 
    <title>Floating Window</title> 
    <script src="Drag.js"></script> 
    </head> 
    <body>
    
    <div id="window" style="position:absolute; z-index:10; left:0px; top:0px; width:100%; height:100%; 
    
    background-color:#CCCCCC;">
    
    <div align="center"><img src="images/logo.jpg" width="455" height="54">     </div> 
    
    <div style="position:absolute; top:3px; left:95%; float:right;" onClick="this.parentNode.parentNode.style.display = 'none';"> 
    
    <img src="images/close_button.gif" width="48" height="14" border="0"></a></div>
    <div align="center"><img src="images/interstitial.jpg" width=700 height=373 
    
    alt=""></div>
           
       </div> 
    
    </body>
    </html>
    thanks!

    Lisa

  2. #2
    Join Date
    Dec 2008
    Location
    Portsmouth, UK
    Posts
    1,891
    Thanks
    2
    Thanked 441 Times in 435 Posts

    Default

    Code:
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=windows-1250">
    <title>Floating Window</title>
    <script src="Drag.js"></script>
    </head>
    <body onload="setTimeout(function(){ document.getElementById('window').style.visibility='hidden'; },7000);">
    
    <div id="window" style="position:absolute; z-index:10; left:0px; top:0px; width:100%; height:100%;
    
    background-color:#CCCCCC;">
    
    <div align="center"><img src="images/logo.jpg" width="455" height="54">     </div>
    
    <div style="position:absolute; top:3px; left:95%; float:right;" onClick="this.parentNode.parentNode.style.display = 'none';">
    
    <img src="images/close_button.gif" width="48" height="14" border="0"></a></div>
    <div align="center"><img src="images/interstitial.jpg" width=700 height=373
    
    alt=""></div>
    
       </div>
    
    </body>
    </html>
    Vic
    God Loves You and will never love you less.
    http://www.vicsjavascripts.org/Home.htm
    If my post has been useful please donate to http://www.operationsmile.org.uk/

  3. #3
    Join Date
    Feb 2010
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Oh cool thanks will try that! i had something like this:

    <script type="text/javascript">
    function nodeHide() {
    this.parentNode.parentNode.style.display = 'none';
    }

    document.onload = setTimeout("nodeHide()", 7000);
    </script>

    but it wasnt working

  4. #4
    Join Date
    Feb 2010
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Thanks for the suggestion but i was getting an error from the start and it wasn't timing out. I changed it to this below and now it is timing out but now im getting an error instead of the window closing...

    <script type="text/javascript">
    <!--
    function nodeHide(){
    this.parentNode.parentNode.style.display = "none"
    }

    //-->
    </script>
    </head>
    <body OnLoad = "setTimeout('nodeHide()', 7000)">

    It says this.parentNode.parentNode. is null or not an object?

  5. #5
    Join Date
    Feb 2010
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    ahh i fixed it to this and it works!

    thanks

    <body onload="setTimeout(function(){ document.getElementById('window').style.display='none'; },7000);">

  6. #6
    Join Date
    Feb 2010
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    More issues... apparently this only works in FF?

    <body onload="setTimeout(function(){ document.getElementById('window').style.display='none'; },7000);">

    i cant get it to work in IE

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
  •