I’m not understanding what I am doing wrong, this is supposed to add contextmenu attribute to images to return false. I tried ‘img[i].contextmenu=”return false”;’ too.
var img = document.body.getElementsByTagName("img");
var i = 0;
while (i < img.length) {
img[i].setAttribute("contextmenu", "return false;");
i++;
}
I’m basically wanting to turn this jQuery into JavaScript:
$(document).ready(function() {
$("img").bind("contextmenu", function(e) {
return false;
});
});
Event attributes start with
onso tryDEMO