Search code examples
javascripteventsfirefox-addondom-eventsdouble-click

dblclick event in Firefox extension


I'm using the following code in firefox extension, that should alert when double click event occur, but when I double click nothing happens.

var Test = {
x: function(e) {
  alert(e.target.defaultView.location.href);
}

}

window.addEventListener("dblclick", function(e) { Test.x(); }. false);

Solution

  • Try changing the dot to a comma before the last parameter:

    window.addEventListener("dblclick", function(e) { Test.x(); }, false);
    //                                                          .^.
    //                                                           | here...
    

    Update

    Your closure also expects a parameter e to be passed to it:

    window.addEventListener("dblclick", function(e) { Test.x(e); }, false);