/**
*获取页面元素的滚动位置
@param {DOM} el Dom元素
*return {Object} 元素滚动位置对象
*/
function getScroll (el) {
var d = el,
doc = document,
body = doc.body,
docElement = doc.documentElement,
l,
t,
ret,
isStrict = document.compatMode == "CSS1Compat",
isIE = /msie/.test(navigator.userAgent);
if (d == doc || d == body) {
if (isIE && isStrict) {
l = docElement.scrollLeft;
t = docElement.scrollTop;
} else {
l = window.pageXOffset;
t = window.pageYOffset;
}
ret = {
left: l || (body ? body.scrollLeft : 0),
top: t || (body ? body.scrollTop : 0)
};
} else {
ret = {
left: d.scrollLeft,
top: d.scrollTop
};
}
return ret;
}