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
    Nov 2010
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    transparent and onclick

    I need a code that makes the following:

    1. I need a link to a certain website
    2. If someone click that link it opens in new tab and it makes 1. link invisible and show a another link on the same place with a time delay of 5 seconds

  • #2
    Supreme Master coder! Philip M's Avatar
    Join Date
    Jun 2002
    Location
    London, England
    Posts
    18,079
    Thanks
    203
    Thanked 2,542 Times in 2,520 Posts
    You can't tell a browser to open in a new tab, just a new window (which it's up to the browser to interpret as a new tab). Opening in a new tab is behaviour which is configured by the user and, as far as I know, only by the user. This is the best you can do.

    Code:
    <div id = "mydiv1" style="display:block">
    <a href="http://www.google.com" target="_blank" onclick = "hideFirst()">First Link Text</a>
    </div>
    
    <div id = "mydiv2" style="display:none">
    <a href="http://www.javascriptkit.com" target="_blank">Second Link Text</a>
    </div>
    
    <script type = "text/javascript">
    function hideFirst() {
    document.getElementById("mydiv1").style.display="none";
    setTimeout("showSecond()",5000);
    }
    
    function showSecond() {
    document.getElementById("mydiv2").style.display="block";
    }
    </script>
    "Insanity is doing the same thing over and over again, but expecting different results." - Rita Mae Brown


  •  

    Posting Permissions

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