With the following code you can disable text selection in the entire webpage, except inputs and textareas:
document.getElementsByTagName("BODY")[0].onselectstart = function(e) {
if (e.target.nodeName != "INPUT" && e.target.nodeName != "TEXTAREA") {
e.preventDefault();
return false;
}
return true;
};
Alternatively, if you want to disable text selection completely you can use this code:
document.getElementsByTagName("BODY")[0].onselectstart = function(e) {
e.preventDefault();
return false;
};
If you want to disable text selection only for the elements having the class .e-pdfviewer-pageCanvas you can use:
var pdfviewer = document.getElementsByClassName("e-pdfviewer-pageCanvas");
for (var i = 0; i < pdfviewer.length; i++) {
pdfviewer[i].onselectstart = function(e) {
e.preventDefault();
return false;
};
};
[EDIT]:
If none of the aforementioned solved your issue, use the following code in your HTML <body> or the element you want to disable text selection for specifically:
<body onselectstart = "return false;" style = "-moz-user-select: none;">...</body>
Or in JavaScript:
document.getElementsByTagName("BODY")[0].onselectstart = function(e) {return false};
document.getElementsByTagName("BODY")[0].style.mozUserSelect = "none";