开发者

Fast clicking on IE has slower response than firefox, chrome and safari. Why? (I'm using jquery)

Fast clicking on IE has slower response than firefox, chrome and safari. Why? (I'm using jque开发者_JAVA技巧ry)


It's because Internet Explorer interprets two fast clicks in a row as one single-click, followed by one double-click, while the other browsers interpret it as two single-clicks and a double-click.

Try testing this to see how each browser reacts to a double-click.

<html>

<head>
<script type='text/javascript'>

function onclick_test()
{
 var console = document.getElementById('console');
 console.appendChild(document.createTextNode('onclick'));
 console.appendChild(document.createElement('br'));
}

function ondblclick_test()
{
 var console = document.getElementById('console');
 console.appendChild(document.createTextNode('ondblclick'));
 console.appendChild(document.createElement('br'));
}

</script>
</head>

<body>

<span style='border:1px solid blue;' onclick='onclick_test();' ondblclick='ondblclick_test();'>Click me</span>

<div id='console'></div>

</body>
</html>


WebKit's SunSpider test (which covers a wide selection of pure-JavaScript functionality). Here is the break down:

Fast clicking on IE has slower response than firefox, chrome and safari. Why? (I'm using jquery)


(source: ejohn.org)

as you can see, IE is slow on javascript.

source and more here.


It is due to the speed of the JavaScript engine inside of the browser. IE is typically the slowest (depending on the version being used).


I think the problem is that IE apparently doesn't fire click when it fires dblclick unlike other browsers, so some clicks are lost in th ether (because they trigger dblclick). I fixed (hacked) this problem by repeating the same handler code for dblclick as for click if browser is IE ($.browser.msie). It's an hack, not a good solution. If someone knows how to fix this properly please let me know.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜