当我双击时,似乎clearTimeout(timer)
不起作用,并且代码调用了function activated(currentactiveid);
setTimeout("activated2('" + currentactiveid + "')", 2000);
还要引用里面的函数 timer
。所以最后我认为问题在于clearTimeout
找不到变量timer
。
HTML:
<td class='td2' id='currentid1' ondblclick='activatedd(this);' onclick='dclickornot(this);'>Some Text</td>
Javascript:
// Single Click
function dclickornot(e)
{
var currentactiveid = e.id;
var timer = setTimeout("activated2('" + currentactiveid + "')", 2000);
}
// Double Click
function activatedd(e)
{
clearTimeout(timer);
var currentactiveid = e.id;
activated(currentactiveid);
}