+ -
当前位置:首页 → 问答吧 → IE attachEvent 的问题

IE attachEvent 的问题

时间:2011-12-19

来源:互联网

function load_events()
{
var mz_editor_events = document.getElementById("mz_ico").getElementsByTagName("*");
var event = event || window.event;


for(i=0 ; i<mz_editor_events.length ; i++)
{
if(mz_editor_events[i].className == "mz_icon_inline")
{
try{
  mz_editor_events[i].addEventListener("mousemove",function(){e_move(this);},true);
mz_editor_events[i].addEventListener("mouseout",function(){e_out(this);},true);
mz_editor_events[i].addEventListener("mousedown",function(){e_down(this);},true);
  }
  catch(e){
  mz_editor_events[i].attachEvent("onmousemove",function(){e_move(mz_editor_events[i]);});
mz_editor_events[i].attachEvent("onmouseout",function(){e_out(mz_editor_events[i]);});
mz_editor_events[i].attachEvent("onmousedown",function(){e_down(mz_editor_events[i]);});

  }
}
}
}

function e_move(id)
{ id.className = "mz_icon_online";}
function e_out(id)
{ id.className = "mz_icon_inline";}

我的firefox 下面 和ie9下面都正常


ie6-ie8 会报id underfined is null or not an obiect

作者: SHANDIANDIAN   发布时间: 2011-12-19

function load_events(event)
{
}

作者: zhanghuwoaini   发布时间: 2011-12-19