Results 1 to 8 of 8

Thread: Switch Content Script - Standalone script needed!...

  1. #1
    Join Date
    Nov 2010
    Posts
    5
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Question Switch Content Script - Standalone script needed!...

    1) Script Title: Switch Content Script

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

    Hello!... Firstly, thanks for the scripts!...

    Sorry about this but... Could some kind person please update this script so I could store it somewhere else on my site please!...

    Code:
    <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", "div") //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>
    I would like to take it off the page so any help would be very appreciated!...

  2. #2
    Join Date
    Jul 2008
    Location
    Derbyshire, UK
    Posts
    3,033
    Thanks
    25
    Thanked 599 Times in 575 Posts
    Blog Entries
    40

    Default

    Do you mean that you want to pull out the code (less the opening/closing script tags) into a seperate .js file and then reference the code with a link?

    Like <script type="text/javascript" src="switchcontent_load.js" ></script>
    Focus on Function Web Design
    Fast Edit (A flat file, PHP web page editor & CMS. Small, FREE, no database!) | Fast Edit BE (Snippet Manager) (Web content editor for multiple editable regions!) | Fast Apps

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

    beach_borosix (11-11-2010)

  4. #3
    Join Date
    Nov 2010
    Posts
    5
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default

    Quote Originally Posted by Beverleyh View Post
    Do you mean that you want to pull out the code (less the opening/closing script tags) into a seperate .js file and then reference the code with a link?

    Like <script type="text/javascript" src="switchcontent_load.js" ></script>
    Hello!... That's exactly it!... But if you take out the opening and closing tags and put it into a script, it will not work on it's own!... It needs to be updated slightly... I have been trying but I am a simpleton!... Please help!...

  5. #4
    Join Date
    Jul 2008
    Location
    Derbyshire, UK
    Posts
    3,033
    Thanks
    25
    Thanked 599 Times in 575 Posts
    Blog Entries
    40

    Default

    I'm not sure what you mean. I tested it using the method I briefly described and it works fine - no updates to the script are necessary.

    Please post a link to your web page so we can see whats going wrong.
    Focus on Function Web Design
    Fast Edit (A flat file, PHP web page editor & CMS. Small, FREE, no database!) | Fast Edit BE (Snippet Manager) (Web content editor for multiple editable regions!) | Fast Apps

  6. #5
    Join Date
    Jul 2008
    Location
    Derbyshire, UK
    Posts
    3,033
    Thanks
    25
    Thanked 599 Times in 575 Posts
    Blog Entries
    40

    Default

    My test page;
    Code:
    <html>
    <head>
    
    <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>
    
    </head>
    <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>
    
    <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.
    </div>
    
    <h3 id="bobcontent2-title" class="handcursor">Difference betwen Java & JavaScript?</h3>
    <div id="bobcontent2" class="switchgroup1">
    Java is completely different from JavaScript.
    The former is a compiled language while the later is a scripting language.
    </div>
    
    <h3 id="bobcontent3-title" class="handcursor">What is DHTML?</h3>
    <div 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.
    </div>
    
    <script type="text/javascript" src="switchcontent_load.js"></script>
    
    </body>
    </html>
    switchcontent_load.js;
    Code:
    var bobexample=new switchcontent("switchgroup1", "div") //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()
    Focus on Function Web Design
    Fast Edit (A flat file, PHP web page editor & CMS. Small, FREE, no database!) | Fast Edit BE (Snippet Manager) (Web content editor for multiple editable regions!) | Fast Apps

  7. #6
    Join Date
    Nov 2010
    Posts
    5
    Thanks
    1
    Thanked 0 Times in 0 Posts

  8. #7
    Join Date
    Nov 2010
    Posts
    5
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default

    I tried to use the url's you gave me and the text disappeared!...

  9. #8
    Join Date
    Nov 2010
    Posts
    5
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default

    Belay all of that... I didn't put the link at the bottom... I did it and guess what... Thanks and d'oh!...

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
  •