While the text appears fine in Firefox, it remains selectable in Chrome and Internet Explorer. Is there a way to work around this issue? The code snippet was borrowed from another post (which I cannot locate at the moment) so it may be outdated?
// To prevent text selection
function disableSelection(target) {
if (typeof target.onselectstart != "undefined") // Method for Internet Explorer
target.onselectstart = function() { return false }
else if (typeof target.style.MozUserSelect != "undefined") // Method for Firefox
target.style.MozUserSelect = "none"
else // Default method for other browsers like Opera
target.onmousedown = function() { return false }
}
Implementation in code:
disableSelection(document.getElementById("gBar"));