attachEvent ('onmouseover', new Function("Somefuc(someparma);"));
解决方案 »
- JavaScript获取XML中的节点,XML是SOAP格式的
- 动态生成函数的问题
- 请教关于setInterval嵌套的问题??/
- 在windows2000正确,windows xp里出现javaScript错误
- 求正则高手帮忙解决
- ******头都大了!请大哥大姐们帮我验证一下表单(JavaScript菜鸟心痛中)
- 级联下拉框选定传值的一个问题~求解~~UPUP
- 下拉选项select的又一问题!
- javascript中取table或td的背景url(在线等)
- 怎样判断一个表单已经被用户改变?
- 高人进来!!分不够狂加,直到解决问题位置 如何检测到Alt+F4,还有就是如何在不同的浏览器里检测关闭事件
- FireFox里怎么让这句话执行
Surely a staple to event attachment! Regardless to what version you use written by whatever developer, it does what it says it does. And of course as you might of known, I’ve put together quite a handy version myself recently of addEvent() with some help from the contest winner and Mark Wubben along with a few minor syntax adjustments. But just to be fair to Scott Andrew, here is the original that started it all.Scott Andrew’s original addEvent() functionfunction addEvent(elm, evType, fn, useCapture) {
if (elm.addEventListener) {
elm.addEventListener(evType, fn, useCapture);
return true;
}
else if (elm.attachEvent) {
var r = elm.attachEvent('on' + evType, fn);
return r;
}
else {
elm['on' + evType] = fn;
}
}
if (elm.addEventListener) {
elm.addEventListener(evType, fn, useCapture);
return true;
}
else if (elm.attachEvent) {
var r = elm.attachEvent('on' + evType, fn);
return r;
}
else {
elm['on' + evType] = fn;
}
}
用这个兼容性比较好些。