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

onmouseover+setTimeout怪问题
原来的onmouseover函数是onmouseover= "show(this, 'divx01 ', ' ') "     就是实现一个层的显示
现在希望改成延时2秒才显示这个层,我写成

onmouseover= "setTimeout( "show(this, 'divx01 ', ' ') ", "2000 ") "   或者是

onmouseover=setTimeout( "show(this, 'divx01 ', ' ') ", "2000 ")或者是

onmouseover=setTimeout(show(this, 'divx01 ', ' '),2000)

都不行

该这么写呢?

------解决方案--------------------
<span id= "Dynamic " onmouseover= "cc(this) " > cccccccccc </span>


function show(a,b,c){
alert(a.id)
alert(b)
}
//function cc(a){
//setTimeout( "show( "+a+ ", 'divx01 ', ' ') ",5000)
//}
var _st = window.setTimeout;
window.setTimeout = function(fRef, mDelay) {
if(typeof fRef == 'function '){
var argu = Array.prototype.slice.call(arguments,2);
var f = (function(){ fRef.apply(null, argu); });
return _st(f, mDelay);
}
return _st(fRef,mDelay);
}


window.setTimeout(test,1000, 'fason ');
function cc(a){
//setTimeout( "show( "+a+ ", 'divx01 ', ' ') ",5000)
window.setTimeout(show,5000,a, 'divx01 ', 'c ');
}