Forum Moderators: open

Message Too Old, No Replies

onClick with anchor?

is this possible?

         

sldesigns

10:21 pm on May 15, 2006 (gmt 0)

10+ Year Member



I admit, I don't know javascript. So thanks for any input you have.

I have a service page that shows tabs, and when you click on the tab different layers are shown. This part works great.

However, on the home page there are teaser tabs relating to the three service tabs. Each of these has a 'read more' link to get to the service page. BUT, I can only get it to link to the default stage, with the first tab open. I thought maybe adding a target to the services page might work, but it doesn't. See code:

<li id="tab-packaging2"><a name="pack" id="pack" href="#" onClick="MM_showHideLayers('packaging2','','show','shipping2','','hide','warehousing2','','hide')">Packaging</a></li>
<li id="tab-shipping2"><a href="#" onClick="MM_showHideLayers('packaging2','','hide','shipping2','','show','warehousing2','','hide')" name="ship" id="ship">Shipping</a></li>
<li id="tab-warehousing2"><a name="house" id="house" href="#" onClick="MM_showHideLayers('packaging2','','hide','shipping2','','hide','warehousing2','','show')">Warehousing</a></li>

Is it possible to do what I want? Am I on the right track? If not, can you point me to where I can see the station? (may have taken the train analogy a bit far there. Am getting desperate)

thanks

Little_G

4:56 pm on May 16, 2006 (gmt 0)

10+ Year Member



Hi,

You can actually put the javascript in the href:


<li id="tab-packaging2"><a name="pack" id="pack" href="javascript:MM_showHideLayers('packaging2','','show','shipping2','','hide','warehousing2','','hide')">Packaging</a></li>

Andrew

sldesigns

5:24 pm on May 16, 2006 (gmt 0)

10+ Year Member



That cleans up the code, thank you. Using the anchor to link from another page to a specific tab didn't work though, which doesn't make any sense now that the onClick is gone. Any other thoughts?

sldesigns

2:15 pm on May 30, 2006 (gmt 0)

10+ Year Member



perhaps this will clear up my question a bit. The code above is on the page with the tabs (sevices page). What I would like to do is have a link TO this page, where a different tab than the default will be open. Similar to using an anchor link in html to jump to a certain area on a page.

THANKS!

Little_G

11:06 am on May 31, 2006 (gmt 0)

10+ Year Member



Hi,

I think you'll have to use query strings, i.e. "http://www.domain.com/page.html?tab=1".

Take a look here [activsoftware.com]
then it would be something like:


switch(getQueryVariable("tab")){
case '1': showTab(1); break;
case '2': showTab(2); break;
default: showTab(1); break;
}

Andrew

sldesigns

11:36 am on May 31, 2006 (gmt 0)

10+ Year Member



OK, this looks promising. One more queston: I replace "1" from "tab=1" with the tab name (ie "tab-packaging"), correct? Of course a number is simplier but needed more descriptive names for the css.

Little_G

2:47 pm on May 31, 2006 (gmt 0)

10+ Year Member



Hi,

yes, you can use whatever you like.

Andrew