Results 1 to 5 of 5

Thread: Switch Content Script: absolute vs relative URL

  1. #1
    Join Date
    Jul 2008
    Location
    Colorado, USA
    Posts
    27
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Switch Content Script: absolute vs relative URL

    1) Script Title: Switch Content Script

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

    3) Describe problem: I'm using the script in Wordpress and suspect I need to use an absolute URL to the javascript file. I say this because when I use the script on a static page with a relative URL to the .js file, it works fine. Any ideas?

    Thanks!
    Cway

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

    Default

    On blogs where the URL of each page can be very complex and not always reflective of the true directory structure of your site, yes, it's prudent to just specify an absolute URL to the .js file, ie:

    Code:
    <script type="text/javascript" src="http://mysite.com/scripts/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>
    DD Admin

  3. #3
    Join Date
    Jul 2008
    Location
    Colorado, USA
    Posts
    27
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    That's what I thought, but it doesn't work in Wordpress:
    http://dev.smilefortcollins.com/ask-the-dentist/

    It works on a static page:
    http://www.smilefortcollins.com/test.shtml

    Any suggestions?
    Thanks for the quick response!
    Cway

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

    Default

    On your wordpress page, there is an error with the initialization code for the script:

    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</p>
    <p>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>
    As you can see, there's an inadvertent P tag inside it.
    DD Admin

  5. #5
    Join Date
    Jul 2008
    Location
    Colorado, USA
    Posts
    27
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Fixed! Thanks for the quick response and for the script.

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
  •