Disabling selection of the canvas element
in
Processing with Other Languages
•
2 years ago
Hiya, I want to make the canvas unselectable as it's going to be in the background of my website. Here's my current code...why doesn't this work?
Cheers,
Rob
makeUnselectable = function(elem) {
if (elem == undefined || elem.style == undefined) return;
elem.onselectstart = function() {
return false;
};
elem.style.MozUserSelect = 'none';
elem.style.KhtmlUserSelect = 'none';
elem.unselectable = 'on';
var kids = elem.childNodes;
for (var i = 0; i < kids.length; i++) {
makeUnselectable(kids[i]);
}
};
makeUnselectable($('canvas')[0]);
1