Results 1 to 4 of 4

Thread: Switch Content Script HELP

  1. #1
    Join Date
    Apr 2005
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Switch Content Script HELP

    Hello,
    I was looking for a little help on the Switch Content Script.

    It's Working GREAT but...
    when i click the link to expand the content the browser sends the view back to the very top.

    here is the link to the DynamicDrive Script.
    http://www.dynamicdrive.com/dynamici...tchcontent.htm

    here is a link to my attempt of using this script. Note when you click the SHOW buttons on the Right (click them all) then scroll down to the bottome one and click the hide HIDE link then you will see the browser pop back to the top. I would like to see the browser stay where the link is.
    http://www.crmca.org/sites.php


    HELP?

  2. #2
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,495
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    That is caused by your use of the href="#" which means, goto to the anchor name on this page with no name, or essentially, goto top. That was never suggested as a method when using this script. Here, from the demo page, are the suggested methods:

    HTML Code:
    <!--Optional Expand/ Contact All links. Remove if desired-->
    <div><a href="javascript:sweeptoggle('contract')">Contract All</a> | <a href="javascript:sweeptoggle('expand')">Expand All</a></div>
    
    <h3 onClick="expandcontent(this, 'sc1')" style="cursor:hand; cursor:pointer"><span class="showstate"></span>What is JavaScript?</h3>
    <div id="sc1" class="switchcontent">
    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 onClick="expandcontent(this, 'sc2')" style="cursor:hand; cursor:pointer"><span class="showstate"></span>Difference between Java & JavaScript?</h3>
    <div id="sc2" class="switchcontent">
    Java is completely different from JavaScript- the former is a compiled language while the later is a scripting language.
    </div>
    
    <h3 onClick="expandcontent(this, 'sc3')" style="cursor:hand; cursor:pointer"><span class="showstate"></span>What is DHTML?</h3>
    <div id="sc3" class="switchcontent">
    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>
    If you want to use an anchor (<a ....>something</a>) you can use it without any href= attribute, though that is unusual and may cause problems with some browsers. Substituting <span> tags should be fine. So for:

    Quote Originally Posted by Cale (from Cale's source code)
    HTML Code:
    <a href="#" onClick="expandcontent(this, 'sc1')"style="cursor:hand; cursor:pointer"><span class="showstate"></span></a>
    you could try:

    HTML Code:
    <span onClick="expandcontent(this, 'sc1')" style="cursor:hand; cursor:pointer"><span class="showstate"></span></span>
    Also, notice that you have left out a space between:

    onClick="expandcontent(this, 'sc1')" and style="cursor:hand; cursor:pointer"
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

  3. #3
    Join Date
    Apr 2005
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default give that a try.

    I will give that a try, but eBay is using that method somehow.
    the use the href to #

    http://pages.ebay.com/help/sell/fees.html

    thats exactly how i was hoping it would look.

    -C

  4. #4
    Join Date
    Apr 2005
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Professor jscheuer1 you hit the nail on the head.

    that worked perfect!!
    Thanks a Ton for the quick help!!!

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
  •