Results 1 to 3 of 3

Thread: Switch content hide link inside the expanded div

  1. #1
    Join Date
    Mar 2009
    Posts
    4
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default Switch content hide link inside the expanded div

    1) Script Title: Switch Content Script

    2) Script URL (on DD): http://www.dynamicdrive.com/dynamici...tchcontent.htm

    3) Describe problem:

    I am trying to create a link inside the expanded content that will close that current expanded content. For example a button that says "Hide" and when clicked the current expanded content closes.

    I tried using the collapse all feature, but this collapses all expanded boxes like it is supposed to.

  2. #2
    Join Date
    Aug 2004
    Posts
    9,896
    Thanks
    3
    Thanked 967 Times in 955 Posts
    Blog Entries
    15

    Default

    Try adding the below script to your page:

    Code:
    <script type="text/javascript">
    
    function closeheader(switchinstance, header){
    	var header=document.getElementById(header)
    	switchinstance.contractcontent(header)
    }
    
    </script>
    It lets you contract a header from anywhere on the page, such as inside the content itself. As an example:

    Code:
    <h3 id="bobcontent1-title" class="handcursor">What is JavaScript?</h3>
    
    <div id="bobcontent1" class="switchgroup1">
    JavaScript is a scripting language originally developed by Netscape to add interactivity
    and power to web documents. It is purely client side, and runs completely on the client's browser and computer.
    
    <a href="javascript:closeheader(bobexample, 'bobcontent1-title')">Close</a>
    
    </div>
    Where bobexample should be the variable name of this Switch Content instance, and 'bobcontent1-title' the ID of the header which you wish to collapse.
    DD Admin

  3. The Following User Says Thank You to ddadmin For This Useful Post:

    yahooman122 (04-04-2009)

  4. #3
    Join Date
    Mar 2009
    Posts
    4
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default

    Worked perfectly! Thank you!

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
  •