Well, where you have this or something like it:
Code:
<ul id="maintab" class="shadetabs">
<li class="selected"><a href="#default" rel="ajaxcontentarea">Intro</a></li>
<li><a href="external.htm" rel="ajaxcontentarea">Bird</a></li>
<li><a href="external2.htm" rel="ajaxcontentarea">Dog</a></li>
<li><a href="external3.htm" rel="ajaxcontentarea">Cat</a></li>
<li><a href="external4.htm" rel="ajaxcontentarea" rev="content.css, content.js">Sea Otter</a></li>
</ul>
The one with the class="selected" is the default tab for the page. This condition is evaluated (among other things) a little farther down the page here:
Code:
<script type="text/javascript">
//Start Ajax tabs script for UL with id="maintab" Separate multiple ids each with a comma.
startajaxtabs("maintab")
</script>
We could evaluate something else and change this situation before we invoke startajaxtabs(). For instance, your link to the page could be:
HTML Code:
<a href="tabs.htm?sel=1">Link Text</a>
This will pass the parameter sel=1 to the tabs.htm which we can retrieve like so:
Code:
<script type="text/javascript">
if(location.search!=''){
document.getElementById('maintab').getElementsByTagName('li')[0].className=''
document.getElementById('maintab').getElementsByTagName('li')[parseInt(unescape(location.search).replace(/\D/g, ''))].className="selected"
}
//Start Ajax tabs script for UL with id="maintab" Separate multiple ids each with a comma.
startajaxtabs("maintab")
</script>
In the case of the example sel=1, this will select the second tab (things are usually numbered starting from 0 not from 1 in javascript).
This will only work if no other numbers are being passed in the query string, normally there isn't with regular pages. If you are using server side programming and/or forms with your pages, this may not be the case.
Bookmarks