I’m rather new to writing javascripts, am working on a means to scroll a div containing a small navig menu from an initial, absolutely positioned, location on a page. I’ve got it to work – though the scrolling is a little choppy – probably a lag due to excessive firing of the function. I’m pretty sure the Setimeout() is not the the proper way to implement this, anyone know what is?
[CODE]function shiftY(){
var yVal = getScrollY(); // getScroll() returns the pageYOffset
if (document.getElementById){
if (yVal > 335){
document.getElementById(“databoxLNav”).style.position = “fixed”;
document.getElementById(“databoxLNav”).style.top = “12px”;
}
else if (yVal <= 335 && document.getElementById(“databoxLNav”).style.position == “fixed”){
document.getElementById(“databoxLNav”).style.position = “absolute”;
document.getElementById(“databoxLNav”).style.top = “325px”;
}
}
setTimeout(“shiftY()”, 100)
}