var scrollPos; if (typeof window.pageYOffset != 'undefined') { scrollPos = {x:window.pageXOffset, y:window.pageYOffset}; } else if (typeof document.compatMode != 'undefined' && document.compatMode != 'BackCompat') { scrollPos = {x:document.documentElement.scrollLeft, y:document.documentElement.scrollTop}; } else if (typeof document.body != 'undefined') { scrollPos = {x:document.body.scrollLeft, y:document.body.scrollTop}; }