Created
February 12, 2010 03:46
-
-
Save navarr/302272 to your computer and use it in GitHub Desktop.
Tabbed Navigation for fromREADtoGREEN.com - I'm so proud of it
This file contains hidden or 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
document.loadFuncs = new Array; | |
function loadUp() | |
{ | |
for(i = 0;i < document.loadFuncs.length;i++) | |
{ | |
document.loadFuncs[i](); | |
} | |
} | |
function whenLoad(loadfunc) | |
{ | |
document.loadFuncs[document.loadFuncs.length] = loadfunc; | |
} |
This file contains hidden or 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
function showTab(tab) | |
{ | |
document.location.hash = "#tab-" + tab; | |
} | |
function setDefaultTab(tab) | |
{ | |
document.defaultTab = tab; | |
} | |
function checkHash() | |
{ | |
if(document.location.hash != document.lastHash) | |
{ | |
if(!document.location.hash.split("#tab-")[1]) { tab = document.defaultTab; } | |
else { tab = document.location.hash.split("#tab-")[1]; } | |
if(document.getElementById("content-" + tab)) | |
{ | |
for(var i = 0; i < document.tabs.length; i++) | |
{ | |
$("nav-" + document.tabs[i]).className = ""; | |
$("content-" + document.tabs[i]).style.display = "none"; | |
} | |
$("nav-" + tab).className = "active"; | |
$("content-" + tab).style.display="block"; | |
} | |
document.lastHash = document.location.hash; | |
} | |
} | |
whenLoad(checkHash); | |
whenLoad(function(){ setInterval(checkHash,100); }); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment