Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Javascript, Disable context menu on right click
<!DOCTYPE html>
<html>
<head>
<title>Javascript, Disable context menu on right click</title>
<script type="text/javascript">
if (document.addEventListener) {
document.addEventListener('contextmenu', function (e) {
e.preventDefault();
}, false);
} else {
document.attachEvent('oncontextmenu', function () {
window.event.returnValue = false;
});
}
</script>
</head>
<body>
</body>
</html>
@idodidodi
Copy link

idodidodi commented Jan 24, 2019

It works, thank you.

@firewood3
Copy link

firewood3 commented Oct 11, 2019

Thank you!

@wavyyy1337
Copy link

wavyyy1337 commented Apr 21, 2020

Thank you:)

@hamzaa53
Copy link

hamzaa53 commented Sep 22, 2020

How can i open back with any button?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment