当前位置: 代码迷 >> JavaScript >> (50分)firefox下怎么实现window.event.clientX
  详细解决方案

(50分)firefox下怎么实现window.event.clientX

热度:436   发布时间:2012-03-06 20:47:55.0
(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"; 

  相关解决方案