function getScrollXY(){ var scrOfX = 0, scrOfY = 0; if( typeof( window.pageYOffset ) == 'number' ){ //Netscape compliant scrOfY = window.pageYOffset; scrOfX = window.pageXOffset; } else if( document.body && ( document.body.scrollLeft || document.body.scrollTop ) ) { //DOM compliant scrOfY = document.body.scrollTop; scrOfX = document.body.scrollLeft; } else if( document.documentElement && ( document.documentElement.scrollLeft || document.documentElement.scrollTop ) ) { //IE6 Strict scrOfY = document.documentElement.scrollTop; scrOfX = document.documentElement.scrollLeft; } coords = new Array(); coords[1] = scrOfX; coords[2] = scrOfY; return coords; } function offsetPosition() { var offsetTop = 0; var this_centre2=document.getElementById("sitemenuend"); do { offsetTop += this_centre2.offsetTop; //alert("offsetTop="+offsetTop); } while (this_centre2 = this_centre2.offsetParent); return offsetTop; } function showFixedMenu(){ x = document.getElementById('sitemenuend').offsetLeft; y = document.getElementById('sitemenuend').offsetTop; scll = getScrollXY(); y = offsetPosition(); if(scll[2] > y){ document.getElementById('fm').style.display = "block"; } if(scll[2] < y){ document.getElementById('fm').style.display = "none"; } } function getOffset(elem) { if (elem.getBoundingClientRect) { // "правильный" вариант return getOffsetRect(elem) } else { // пусть работает хоть как-то return getOffsetSum(elem) } } function getOffsetSum(elem) { var top=0, left=0 while(elem) { top = top + parseInt(elem.offsetTop) left = left + parseInt(elem.offsetLeft) elem = elem.offsetParent } return {top: top, left: left} } function getOffsetRect(elem) { // (1) var box = elem.getBoundingClientRect() // (2) var body = document.body var docElem = document.documentElement // (3) var scrollTop = window.pageYOffset || docElem.scrollTop || body.scrollTop var scrollLeft = window.pageXOffset || docElem.scrollLeft || body.scrollLeft // (4) var clientTop = docElem.clientTop || body.clientTop || 0 var clientLeft = docElem.clientLeft || body.clientLeft || 0 // (5) var top = box.top + scrollTop - clientTop var left = box.left + scrollLeft - clientLeft return { top: Math.round(top), left: Math.round(left) } }