When I am selecting bunch of rows by pressing shift key in gridview, the default text selection(dark blue) mixed with my custom row selection color.
How to disable the default text selection in web application.
When I am selecting bunch of rows by pressing shift key in gridview, the default text selection(dark blue) mixed with my custom row selection color.
How to disable the default text selection in web application.
This works for me to disable "selection" in both FF and IE:
// jQuery Solution
$(document).mousedown(function (e)
{
return false;
});
$(document).bind("selectstart", function (e)
{
return false;
});
If you're not using jQuery, here's the plain javascript solution.
// Vanilla Javascript Solution
function attachEvent(element, eventName, handler)
{
if(element.addEventListener)
{
element.addEventListener(eventName, handler, false);
}
else
{
element.attachEvent("on" + eventName, handler);
}
}
attachEvent(document, "mousedown", function (e)
{
if(window.addEventListener)
{
e.preventDefault();
}
return false;
});
attachEvent(document, "selectstart", function (e)
{
return false;
});
Browser select happens when you click somewhere and then shift+mousedown somewhere else, so you need to cancel the second mousedown. To do this, you need to add
return false;
to your onmousedown event handler.
You mean your text gets selected?
You have to disabled text selection during your selection, see here how to do it.