I want to prevent users from highlighting images on a website I'm currently making just because it seems a bit more professional when they can't accidentally highlight any images used for the design.
I have the following javascript which is supposed to work (found it after some googling):
Code:
function DisableSelection()
{
//prevent selecting text in IE
document.onselectstart = new function(){return "false"};
//prevent selecting text in FF
if (window.sidebar)
{
document.onmousedown = DisableText;
document.onclick = EnableText;
}
}
function DisableText(e)
{
return false;
}
function EnableText()
{
return true;
}
I also have onMouseDown="DisableSelection()" inside the tag of each image I don't want them to be able to highlight.
Anyone have any idea why this doesn't work?
Thanks in advance.