Created
May 18, 2010 15:56
-
-
Save wmoxam/405151 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<div class="tab" id="main"> | |
<a href="http://yadda.ya/foo#main">Main</a> | |
... | |
</div> | |
<div class="tab" id="other"> | |
a href="http://yadda.ya/foo#other">Other</a> | |
... | |
</div> | |
.. etc .. | |
function switch_to_tab() | |
{ | |
var hash = document.location.hash; | |
var name = (typeof hash == 'string') ? hash.gsub('#', '') : ''; | |
if(name == '') return; | |
$$('.tab').each(function(tab) { | |
if(tab.id == name) | |
tab.show(); | |
} else { | |
tab.hide(); | |
} | |
} | |
} | |
document.observe('dom:loaded', switch_to_tab); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment