event鼠标坐标位置
function mousePosition(event) {
if (event.pageX || event.pageY) {
return { x: event.pageX, y: event.pageY };
}
return {
x: event.clientX + document.body.scrollLeft - document.body.clientLeft,
y: event.clientY + document.body.scrollTop - document.body.clientTop
};
}
var mousePos = mousePosition(event);
var wrap = document.getElementById('container');
var menu = document.getElementById('rMenu');
var x = wrap.offsetLeft + wrap.clientWidth, y = wrap.offsetTop + wrap.clientHeight;
var w = 0, h = 0;
var left = 0, top = 0;
w = menu.clientWidth;
h = 72;
left = (x - event.clientX >= w) ? event.clientX - wrap.offsetLeft : event.clientX - wrap.offsetLeft - w;
if (mousePos.y < 428)
top = mousePos.y;
else
top = (mousePos.y + h <= y) ? mousePos.y - wrap.offsetTop : mousePos.y - wrap.offsetTop - h;