div位置随鼠标移动

function showdiv(date,errors,obj){
var event = getEvent();
color = obj.bgColor;//alert(color);
obj.bgColor="#FFFFFF";
$("#div").attr("class","divshow");
if (navigator.appName=='Microsoft Internet Explorer') {
  x = event.x;
  y = event.y;
  }else if (navigator.appName=='Netscape') {
  x = event.pageX;
  y = event.pageY;
}
document.getElementById("div").style.left=x+"px";
document.getElementById("div").style.top=y+document.body.scrollTop-40+"px";
$("#div").html("date:"+date+"<br></br>errors:"+errors);
}
function getEvent() // 同时兼容ie和firefox的写法

if(document.all) return window.event; 
func=getEvent.caller; 
while(func!=null){ 
var arg0=func.arguments[0];
if(arg0)
{
if((arg0.constructor==Event || arg0.constructor ==MouseEvent) || (typeof(arg0)=="object" && arg0.preventDefault && arg0.stopPropagation))

return arg0;
}
}
func=func.caller;
}
return null;
}

你可能感兴趣的:(html,IE,Microsoft,firefox)