well. that's definately JavaScript; and the reason it doesn't work well in all browsers is because all browsers have a different idea of what the relationship between windows, frames and documents is. Often, it's just a case of a different object containing the information...
This is code that works for me, (well; I've never had a problem with it on any browser; that's not to say it's going to work on every browser):
function center(object){
object.style.top = (getVScroll() + (getHeight()/2))-(object.offsetHeight/2);
}
Looking at it, I'm quite suprised it's never had a problem; but anyway: the way I use that code is to position an absolutely positioned object one time only... To make an object scroll as the scrollbar does, you could use some interpolator math based on the distance between the center of the scrolled window and the center of the object at any time (which is what they do on the vue site to make the bar "gracefully" slide up and down), or you could have the image "snap" into the center always (like this:
http://www.siteexperts.com/tips/func...s08/page3.asp).
However, you need to make the thing move as the user moves. For that, you need either an event listener or an event invoker. An event listener is the nicest way; they are feedback interfaces that are activated as a response to user or system events, Event invokers are the opposite - at it's roughest, an event invoker just repeatadly sets values in an object (usually using a Timer) and lets the browser deal with re-rendering parts of the page over and over again. Still, you could make it intelligent, and only invoke a change in the graphical layout when a change occurs in the height or offset of the window.
There is an existing listener in some browsers, window.onscroll. if you were to write this in a javascript function:
window.onscroll = function(){center(myObject)};
it would center the object when the user makes a scroll movement. But, onscroll is apparently not supported on all browsers; so catching the "scroll" event across all browsers might be your biggest challenge. Perhaps you'll find the only way you can do it is using a timer :eek:
I'd prescribe some intensive testing of where the onscroll event works and where it doesn't, and where the document.offset property works and where it doesn't, and work with that.