Professional: JavaScript® for Web Developers by Nicholas C. Zakas

Professional: JavaScript® for Web Developers by Nicholas C. Zakas

Author:Nicholas C. Zakas
Language: eng
Format: mobi
Publisher: John Wiley & Sons
Published: 2011-12-13T10:00:00+00:00


var EventUtil = {

//more code here

getButton: function(event){

if (document.implementation.hasFeature("MouseEvents", "2.0")){

return event.button;

} else {

switch(event.button){

case 0:

case 1:

case 3:

case 5:

case 7:

return 0;

case 2:

case 6:

return 2;

case 4:

return 1;

}

}

},

//more code here

};

EventUtil.js

Checking for the feature "MouseEvents" determines if the button property that is already present on event contains the correct values. If that test fails, then the browser is likely Internet Explorer and the values must be normalized. This method can then be used as follows:



Download



Copyright Disclaimer:
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.