日期:2014-05-16  浏览次数:20331 次

(50分)firefox下如何实现window.event.clientX
如题,这个js在ie下能正常显示,怎么修改才能兼容firefox?
function showad(id) {
var addiv = document.getElementById(id);
var x = window.event.clientX;
var y = window.event.clientY;

addiv.className="showad";
addiv.style.top = y+ "px";
addiv.style.left = x+ "px";
}

这是个onMouseOver触发的事件,谢谢~~~
请说的简单一点最好给我个例子,我是个初学者

------解决方案--------------------
onMouseOver="showad(event,'id')"

function showad(e,id) { 
var addiv = document.getElementById(id); 
e=e||event;
var x = e.clientX; 
var y = e.clientY; 

addiv.className="showad"; 
addiv.style.top = y+ "px"; 
addiv.style.left = x+ "px";