R
Richard Cornford
yOff = parseInt(MenuObject.style.height,10) -
(document.all?document.body.scrollTop:window.pageYOffset);
All decision making by object inference is misguided, and in all cases
it is preferable to read scroll values from the global pageX/YOffset
properties as that removes the need to worry about the
root-element/document.compatMode problem in the vast majority of
browsers.
Will be faster then without replacing
document.getElementById('contenxtmenu')
by
MenuObject
?
getElementById potentially searches the entire DOM for the requested
element. Even if optimised to look only in some sort of collection of
IDed elements repeating that process for each reference must be less
efficient than doing it once and holding on to the result of the first
look-up.
Does the same hold for
document.getElementById('contenxtmenu').style
?
Because that's the only object I'll use of the
document.getElementById('contenxtmenu') element.
If the element's style object is only the object you are interested in
then that is the object to which it makes most sense to hold an
appropriately scoped reference rather than repeatedly re-resolving it.
And is it smart to replace:
document.body.scrollLeft
by
document.body.scrollLeft + document.documentElement.scrollLeft
The root-element/document.compatMode problem is not addressed by this
code.
Richard.