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 2 of 2
  1. #1
    New to the CF scene
    Join Date
    Jun 2012
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Can you help me please....

    Hi Guy's, Im looking for a little help if you dont mind.

    I know very little about website code but getting taught very slowly......

    I have a piece of script that I would need to place on my website to conform to European law.

    What I need the code to do is hide the item after a set amount of time IE: 6 or 10 seconds.

    And to be in front of other items on my website, as it hides part of it behide other things.

    The code I have is below:

    <link rel="stylesheet" type="text/css" href="http://www.thehostingfolks.com/cookiemain.css"/>

    <script type="text/javascript" src="http://www.thehostingfolks.com/support-opt-in.js"></script>

    <script type="text/javascript" src="http://www.thehostingfolks.com/require-opt-in.js" read_more="http://www.mywebsite.co.uk/page/privacy_policy/"></script>


    Please can anyone help crack this for me.

    Thank you.

  • #2
    Supreme Master coder! Philip M's Avatar
    Join Date
    Jun 2002
    Location
    London, England
    Posts
    18,316
    Thanks
    203
    Thanked 2,566 Times in 2,544 Posts
    You need to place the message within a <div> with id (say) "mydiv" with style="display:block". Then

    Code:
    <script type = "text/javascript">
    window.onload ="function(){setTimeout(hideTheDiv,6000)"};  // 6000 milliseconds = 6 seconds
    function hideTheDiv() {
    document.getElementById("mydiv").style.display="none";
    }
    
    </script>
    It is important not to have more than one onload statement in the page so you need to check your other code to ensure that is so. You may need to do something like to fire all your functions in one statement:-

    Code:
    <script type="text/javascript">
    window.onload = function() {
    functionOne();
    functionTwo();
    }
    </script>

    Quizmaster: Which national park is situated mostly in Derbyshire?
    Contestant: The Yorkshire Dales

    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.


  •  

    Posting Permissions

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