Hi there
I'm testing a jQuery script (see below). What it does is that it highlights in the menu which part of the webpage you are currently on. Basically, no problem using it.
- var topMenu = jQuery("#nav ul"),
- topMenuHeight = topMenu.outerHeight() + 15,
- menuItems = topMenu.find("a"),
- scrollItems = menuItems.map(function () {
- var item = jQuery(jQuery(this).attr("href"));
- if (item.length) return item
- });
- jQuery(window).scroll(function () {
- var fromBottom = jQuery(this).scrollBottom() + topMenuHeight;
- var cur = scrollItems.map(function () {
- if (jQuery(this).offset().bottom < fromTop) return this
- });
- cur = cur[cur.length - 1];
- var id = cur && cur.length ? cur[0].id : "";
- menuItems.parent().removeClass("active").end().filter("[href=#" + id + "]").parent().addClass("active")
- });
But when I make the website scroll to bottom of the page on load (see below), the script doesn't seem to work.
- <body onload="window.location.hash = 'home'">
Any ideas? Thank you very much!