Forum Moderators: open
<snip>
and I am having trouble trying to resolve an issue relating to the scrolling navigation panel. When the user scrolls down the list and clicks on a link the new page is reloaded but the position in the navigation panel is forgotten and the content jumps to the top. :(
Is there any way to resolve this? Any assistance would be appreciated.
[edited by: eelixduppy at 3:46 am (utc) on Oct. 15, 2009]
[edit reason] no URLs, please [/edit]
function setScroll() {
var div = document.getElementById("sbx_nav");
if (div === null) { return div; }
var m = window.location.search.match(/scrTop=\d+/);
var num = (m === null) ? 0 : m[0].replace(/scrTop=/,'');
div.scrollTop = num;
var links = div.getElementsByTagName("a");
for (var i = 0; i < links.length; i++) {
addListener(links[i], 'click', (function (el,anchor) {
return function () {
var scrTop = 'scrTop=' + el.scrollTop;
anchor.href += (/\?/.test(anchor.href)) ? '&'+scrTop : '?'+scrTop;
return true;
};
})(div,links[i]));
}
};function addListener(el,evt,func) {
if (el.addEventListener){ //standard
el.addEventListener(evt,func,false); //do not use "on" to prefix the event here
} else if (el.attachEvent){ //IE
el.attachEvent('on'+evt,func);
}
}addListener(window, 'load', setScroll);