That works perfectly - interestingly it only works relative to the htm file, not the js file (which I understand is the norm!) but it works exactly right - man I'm actually beginning to understand this stuff! It's cool!
Now I'm going to try and work something out myself - the window keeps jumping up and down when I click each link (it seems pretty random - it's just between 1-40pxs jumps but it's a little annoying and breaks the super-smooth glossy look of my all-singing all-dancing mag!
So I've found a likely suspect:
var topPos = getTopPos(elementToShow);
window.scrollTo(0,Math.max(0,topPos - elementToShow.offsetHeight));
if(tocStyle==1)return false;
So this looks like you're creating a var called topPos and that's referring to the function gettoppos:
function getTopPos(inputObj)
{
var returnValue = inputObj.offsetTop;
while((inputObj = inputObj.offsetParent) != null){
returnValue += inputObj.offsetTop;
}
return returnValue;
}
And you're setting the top position to the height of the current chapter item?!
And damn I'm lost! Is this garbage or am I on the right tracks?
It looks like:
window.scrollTo(0,Math.max(0,topPos - elementToShow.offsetHeight));
Is my prime suspect - this looks like it's scrolling the window but I can't understand:
(0,Math.max(0,topPos - elementToShow.offsetHeight));
guessing is the first 0 for the x pos of the screen and the second for the y?
that'd mean math.max is then following the same logic with the 0 being the x and the y being toppos - elementtoshow.offsetheight
so I 'could' just change it to:
(0,Math.max(0,0));
Or even:
(0,0);
AND IT WORKS!
Cool! - I know it's probably an incredibly inefficient way of doing things, but I don't want to break it all and I feel I'm actually understanding this language now...
Look out for my amazing scripts I'll be submitting to your site in a couple of months!
[/code]