Results 1 to 7 of 7

Thread: Contractible Headers Script Help Needed

  1. #1
    Join Date
    Jan 2008
    Posts
    15
    Thanks
    10
    Thanked 0 Times in 0 Posts

    Default Contractible Headers Script Help Needed

    Script: Contractible Headers Script
    http://www.dynamicdrive.com/dynamicindex1/navigate2.htm

    -------------------------------------------------------------

    Hi, is it possible to put all the text in the script in a .js file? Cause its taking up quite alot of space or do i have to keep it this way?

    Also, how do i get rid of the "enter" between my headers?


    -Will

  2. #2
    Join Date
    Aug 2004
    Posts
    10,143
    Thanks
    3
    Thanked 1,008 Times in 993 Posts
    Blog Entries
    16

    Default

    You should use Switch Content script, which is a more robust version of the above that should do both of what you're asking above a lot easier.

  3. #3
    Join Date
    Jan 2008
    Posts
    15
    Thanks
    10
    Thanked 0 Times in 0 Posts

    Default

    Hm, the enters between the headers are also present in the Switch Content Script, can you remove them there?

  4. #4
    Join Date
    Aug 2004
    Posts
    10,143
    Thanks
    3
    Thanked 1,008 Times in 993 Posts
    Blog Entries
    16

    Default

    Yes, with a little tweaking apparently though. First, you'd change both the headers and the content wrappers to SPAN tags. A full example:

    Code:
    <script type="text/javascript" src="switchcontent.js" >
    
    /***********************************************
    * Switch Content script- (c) Dynamic Drive (www.dynamicdrive.com)
    * This notice must stay intact for legal use.
    * Visit http://www.dynamicdrive.com/ for full source code
    ***********************************************/
    
    </script>
    
    <style type="text/css">
    
    /*Style sheet used for demo. Remove if desired*/
    .handcursor{
    cursor:hand;
    cursor:pointer;
    }
    
    </style>
    
    <body>
    
    <h2>Demo 1</h2>
    
    <div><a href="javascript:bobexample.sweepToggle('contract')">Contract All</a> | <a href="javascript:bobexample.sweepToggle('expand')">Expand All</a></div>
    
    <span id="bobcontent1-title" class="handcursor">What is JavaScript?</span> <span 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.
    </span>
    
    <br /><br />
    
    <span id="bobcontent2-title" class="handcursor">Difference betwen Java & JavaScript?</span>
    <span id="bobcontent2" class="switchgroup1">
    Java is completely different from JavaScript.
    The former is a compiled language while the later is a scripting language.
    </span>
    
    <br /><br />
    
    <span id="bobcontent3-title" class="handcursor">What is DHTML?</span>
    <span id="bobcontent3" class="switchgroup1">
    DHTML is the embodiment of a combination of technologies- JavaScript, CSS, and HTML.
    Through them a new level of interactivity is possible for the end user experience.
    </span>
    
    
    
    <script type="text/javascript">
    // MAIN FUNCTION: new switchcontent("class name", "[optional_element_type_to_scan_for]") REQUIRED
    // Call Instance.init() at the very end. REQUIRED
    
    var bobexample=new switchcontent("switchgroup1", "span") //Limit scanning of switch contents to just "div" elements
    bobexample.setStatus('<img src="http://img242.imageshack.us/img242/5553/opencq8.png" /> ', '<img src="http://img167.imageshack.us/img167/7718/closedy2.png" /> ')
    bobexample.setColor('darkred', 'black')
    bobexample.setPersist(true)
    bobexample.collapsePrevious(true) //Only one content open at any given time
    bobexample.init()
    </script>
    Then inside switchcontent.js, do a search and replace, replacing all instances of "block" with "inline" instead.

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

    WillAllon (04-08-2008)

  6. #5
    Join Date
    Jan 2008
    Posts
    15
    Thanks
    10
    Thanked 0 Times in 0 Posts

    Default

    hm i did what you said and i got rid of some enters but not the one i wanted :s, i get this now :

    Last edited by WillAllon; 04-08-2008 at 02:25 AM.

  7. #6
    Join Date
    Feb 2008
    Location
    Cebu City Philippines
    Posts
    1,160
    Thanks
    17
    Thanked 277 Times in 275 Posts

    Default

    Remove the <br/> tags.
    Learn how to code at 02geek

    The more you learn, the more you'll realize there's much more to learn
    Ray.ph!

  8. The Following User Says Thank You to rangana For This Useful Post:

    WillAllon (04-08-2008)

  9. #7
    Join Date
    Jan 2008
    Posts
    15
    Thanks
    10
    Thanked 0 Times in 0 Posts

    Default

    omg, it was that simple lmao, thx rangana.

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
  •