Using below code, we can prevent majority of uses from right clicking over a page and choosing “View Source”, or right clicking over an image and saving it.
Some times there might be the requirement to disable the pop up menu on click of right button.
Programmers may need to disable right click to prevent user from saving the images on the page or viewing the source of the page.
function clickIE() { if (document.all) { return false } } function clickNS(e) { if (document.layers || (document.getElementById && !document.all)) { if (e.which == 2 || e.which == 3) { return false } } } if (document.layers) { document.captureEvents(Event.MOUSEDOWN); document.onmousedown = clickNS; } else { document.onmouseup = clickNS; document.oncontextmenu = clickIE; } document.oncontextmenu = new Function("return false");