阻止Google Dictionary在双击Canvas时抛出错误?

时间:2013-07-16 04:45:48

标签: javascript html canvas

每次我双击我设置的画布时,都会收到此错误:

Error in event handler for 'undefined': IndexSizeError: DOM Exception 1 Error: Index or size was negative, or greater than the allowed value.
    at M (chrome-extension://mgijmajocgfcbeboacabfgobmjgjcoja/content_js_min.js:17:154)
    at null.<anonymous> (chrome-extension://mgijmajocgfcbeboacabfgobmjgjcoja/content_js_min.js:19:417)
    at chrome-extension://mgijmajocgfcbeboacabfgobmjgjcoja/content_js_min.js:1:165
    at <error: illegal access>
    at Event.dispatchToListener (event_bindings:356:21)
    at Event.dispatch_ (event_bindings:342:27)
    at Event.dispatch (event_bindings:362:17)
    at Object.chromeHidden.Port.dispatchOnMessage (miscellaneous_bindings:273:22)

我相信Google Dictionary。我该如何防止这种情况?我已经阻止了这样的默认设置:

canvas.addEventListener('mousedown', function(evt) {
        evt.preventDefault();}, false);

canvas.addEventListener('mouseup', function(evt) {
        evt.preventDefault();}, false);

不幸的是,感谢您的帮助,似乎没有任何效果!

修改:应该在Chrome中添加此内容

编辑:刚刚发现它特定于Chrome版本28.0.1500.71,似乎不会影响早期版本。

1 个答案:

答案 0 :(得分:0)

而不是mousedown mouse up尝试使用

canvas.addEventListener('dblclick', function(evt) {
        evt.preventDefault();}, false);

在jquery中工作,所以它应该使用js

http://www.quirksmode.org/js/events_mouse.html