I\'m implementing item selection functionality in javascript (using jQuery). item is a li that contains some html.
the user can click on one item (makes it select
I have an application like that. Trick is, I wanted to allow selection, but I also wanted Ctrl-click and Shift-click for selecting items.
What I found was that everyone but IE allows you to beat this by canceling the mousedown event, and in IE what works best is to temporarily disable onselectstart:
$("#id").mousedown(function (e) {
if (e.ctrlKey || e.shiftKey) {
// For non-IE browsers
e.preventDefault();
// For IE
if ($.browser.msie) {
this.onselectstart = function () { return false; };
var me = this; // capture in a closure
window.setTimeout(function () { me.onselectstart = null; }, 0);
}
}
});