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

请问元素对象的事件名是否可写成变量,火狐可以,不知道ie如何写

var box=document.getElementById('div01');
var type='onclick';
box[type]=function(e){
  alert('here!')
}

------解决方案--------------------
都可以啊  ie7dao9试了下没问题啊
------解决方案--------------------
IE试下用
box.attachEvent(type , function(e){
  alert('here!')
});
------解决方案--------------------
缺少 <body> 标签