I am trying to implement a simple floating navigation using the DOM and Javascript. The following script is triggered using the onscroll event, but nothing happens and debugging through firebug has not been all that enlightening.
function float_nav() {
nav = document.getElementById("nav_container");
offset = window.pageYOffset + 'px;';
nav.style.top=offset;
}
You don’t have to add the
;at the end ofpx. Otherwise I see nothing wrong.Additional: why don’t you use jQuery or something similar?