Results 1 to 9 of 9

Thread: Tab Content Script - change on load?

  1. #1
    Join Date
    Oct 2006
    Posts
    40
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Tab Content Script - change on load?

    1) Script Title:

    Tab Content Script

    2) Script URL (on DD):

    http://www.dynamicdrive.com/dynamici...abcontent2.htm

    3) Describe problem:

    I need a on load function for this script for my body tag which will do an auto switch to 'sc2'.. for eg.

    Code:
    <body onLoad="expandcontent('sc2', this);">
    However this doesnt work for me. Anyone?

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

    Default

    Hmmm are you basically just trying to load the tab content "sc2" when the page initially loads? The script provides an internal way to do this:

    Code:
    //Set tab to intially be selected when page loads:
    //[which tab (1=first tab), ID of tab content to display]:
    var initialtab=[2, "sc2"]

  3. #3
    Join Date
    Sep 2005
    Location
    India
    Posts
    1,627
    Thanks
    6
    Thanked 107 Times in 107 Posts

    Default

    posted by: ak7861
    Code:
    <body onLoad="expandcontent('sc2', this);">
    The above mentioned code will not work because if you look at the function call closely there is a 'this' which is used to pass the current object from the hyperlinks (tabs). In the original source code the author has used this with the hyerlinks to pass the current hyperlink object from which they are calling it.

    Now either you can go with the solution provided by DDAdmin or you call the expandcontent() and pass the hyperlink obect to which you want to switch.

  4. #4
    Join Date
    Oct 2006
    Posts
    40
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    so what do i put exactly?

  5. #5
    Join Date
    Mar 2006
    Location
    Illinois, USA
    Posts
    12,164
    Thanks
    265
    Thanked 690 Times in 678 Posts

    Default

    This...
    Quote Originally Posted by ddadmin
    Hmmm are you basically just trying to load the tab content "sc2" when the page initially loads? The script provides an internal way to do this:

    Code:
    //Set tab to intially be selected when page loads:
    //[which tab (1=first tab), ID of tab content to display]:
    var initialtab=[2, "sc2"]
    Daniel - Freelance Web Design | <?php?> | <html>| español | Deutsch | italiano | português | català | un peu de français | some knowledge of several other languages: I can sometimes help translate here on DD | Linguistics Forum

  6. #6
    Join Date
    Oct 2006
    Posts
    40
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Code:
    <? if (isset($_COOKIE["sspoll1"])) { ?><body><script>//Set tab to intially be selected when page loads:
    [which tab (1=first tab), sc2]:
    var initialtab=[2, "sc2"]</script><? } else { ?>

    i tried this.. doesnt work..

  7. #7
    Join Date
    Sep 2005
    Location
    India
    Posts
    1,627
    Thanks
    6
    Thanked 107 Times in 107 Posts

    Default

    Code:
    var initialtab=[2, "sc2"]
    This worked correctly for me. It loaded the 2nd tab as the default one rather than the first tab.

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

    Default

    ak7861:
    Are you trying to use PHP to output this script somehow based on PHP's cookie value? That's probably the source of your problem- how you're integrating the two, which unfortunately only you know the full details (ie: have access to the entire PHP server side code).

  9. #9
    Join Date
    Oct 2006
    Posts
    40
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Okay. I know where I went wrong. I didn't realize that the code you gave me was part of the script itself. So I just added the php cookie code in there, so if the cookie exists, it loads the second slide.

    Thanks!

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
  •