Script.aculo.us is a higher-level framework that deals with effects
and UI components. Prototype is the analog to MooTools, and below is
an (untested) example of how you'd do this with Prototype. (Keep in
mind, though, that there's very little framework-specific code in
here, and all frameworks would approach this in similar ways.)
Cheers,
Andrew
function makeFixed(element) {
element = $(element);
// Make sure that the element's "offset parent" is the document
itself;
// i.e., that it has no non-statically-positioned parents
element.setStyle({ position: "absolute" });
function adjust() {
// Set the element's CSS "top" to the scroll offset of the window
element.style.top = window.scrollTop + "px";
}
// Re-adjust whenever the window scrolls
Event.observe(window, "scroll", adjust);
adjust();