Skip to content

Instantly share code, notes, and snippets.

@FelipeBudinich
Last active February 18, 2022 10:24
Show Gist options
  • Save FelipeBudinich/1dbe3c1e58901d24d7e3 to your computer and use it in GitHub Desktop.
Save FelipeBudinich/1dbe3c1e58901d24d7e3 to your computer and use it in GitHub Desktop.
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

It works, thank you.

@firewood3
Copy link

Thank you!

@wavyyy1337
Copy link

Thank you:)

@hamzaa53
Copy link

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