attachEvent ('onmouseover', new Function("Somefuc(someparma);"));

解决方案 »

  1.   

    如果someparma是一个对象来的,不知clare2003(忘情火)的方法行不行
      

  2.   

    addEvent()
    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;
    }
    }
      

  3.   

    function 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;
    }
    }
    用这个兼容性比较好些。