When I created my tumblr theme, I wanted to create a top menu with automatic highlighting. For that, I have created the following code. It utilizes jquery for simplicity
It automatically looks at the current URL, then searches the top menu with the matching href. It then adds the “selectedmenu” class to that <li>. If you choose to implement this you’ll need to have this class defined in your CSS.
Comment if you find this helpful.
Tal
<script type="text/javascript" src="http://code.jquery.com/jquery-1.4.2.min.js">
</script>
<script type="text/javascript">
$(document).ready(function(){
// do stuff when DOM is ready
var activeURI = getURI(document.URL);
$("#topmenu li a[href=" + activeURI + "]").parent().addClass('selectedmenu');
});
function getURI(mystr){
var s0 = mystr.split("\?")
var s1 = s0[0].split("http://");
var s2 = s1[1].split("/");
var rt = "/";
for (var i = 1; i < s2.length; i++) {
rt = rt + s2[i];
if (i + 1 < s2.length) {
rt += "/";
}
}
return (rt);
}
</script>