www.webdeveloper.com
Results 1 to 6 of 6

Thread: Double click on Home (to get it to hide?)

  1. #1
    Join Date
    Jul 2012
    Posts
    4

    Double click on Home (to get it to hide?)

    Hi guys,

    This has been driving me crazy for a few days. I have an entire menu in javascript. The only way to get home to dissapear is to click it twice. I want Home to show when the user gets to the index page, however I want to disappear when another menu is clicked. Right now when I click on About home stays on the top and about shows below it. However, if I double click on Home and then click on About it works just fine? Any ideas?

    <html><head>

    <script type="text/javascript">
    var _hidediv = null;
    function showdiv(id) {
    if(_hidediv)
    _hidediv();
    var div = document.getElementById(id);
    div.style.display = 'block';
    _hidediv = function () { div.style.display = 'none'; };
    }
    </script>
    <!-- end of script for page tabs -- modification -->

    </head>

    <body><div class="content">

    <fieldset class="colorLightBg">


    <div class="contentBox colorLightBg minHeight">
    <div class="contentBand colorBandBg">


    <!-- start of page tabs -->
    <div class="pcheckbox" style="padding-top:0px;;">
    <input type="button" id="btnhome" class="buttonSubmit" value="Home" onclick="showdiv('homeInfo'); " href="#">
    <input type="button" id="btnabout" class="buttonSubmit" value="About" onclick="showdiv('aboutInfo'); " href="#">

    </div>

    <div id="homeInfo" style="padding:10px;">
    <h2>Welcome!</h2>
    HOME!!!
    <p style="padding:10px;">
    </p><h2>Part of Home</h2><p></p><p></p>
    </div> <!-- About Begin -->
    <div id="aboutInfo" style="display:none;padding:10px;">
    <h2>About Us</h2>
    <p>ABOUT</p>

    <p></p>
    </div>
    <!-- About End --></div></div></fieldset></div></body></html>

  2. #2
    Join Date
    May 2004
    Location
    chennai, tamil nadu, India
    Posts
    437
    How about something like this

    Code:
    if(_hidediv)
    {
    _hidediv();
    }
    else
    {
    
    document.getElementById('homeInfo').style.display = 'none';
    
    
    
    }
    Chris, Senior Developer,
    www.Chrisranjana.com

  3. #3
    Join Date
    Jul 2012
    Posts
    4
    Quote Originally Posted by chrisranjana View Post
    How about something like this

    Code:
    if(_hidediv)
    {
    _hidediv();
    }
    else
    {
    
    document.getElementById('homeInfo').style.display = 'none';
    
    
    
    }
    Thanks for the quick response. That disabled everything. Unless I placed it in the wrong area. I placed your code and replaced this:

    if(_hidediv)
    _hidediv();
    var div = document.getElementById(id);
    div.style.display = 'block';
    _hidediv = function () { div.style.display = 'none'; };
    }

  4. #4
    Join Date
    Jul 2012
    Posts
    4
    http://goo.gl/9Yxfw

    Here's the link to test out. If you click "About" the home part stays on the top. However, if you click on "Home" first, and then "About", it works just fine. The "Home" disappears and it works flawlessly. I'm stumped.

  5. #5
    Join Date
    May 2004
    Location
    chennai, tamil nadu, India
    Posts
    437
    It should replace only the code
    Code:
    if(_hidediv)
    _hidediv();
    The rest should stay the same
    Chris, Senior Developer,
    www.Chrisranjana.com

  6. #6
    Join Date
    Jul 2012
    Posts
    4
    Quote Originally Posted by chrisranjana View Post
    It should replace only the code
    Code:
    if(_hidediv)
    _hidediv();
    The rest should stay the same
    THANK YOU!!!! I think that did it Much thanks!!!

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

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



Recent Articles