0
<!doctype html>
<html lang="pt-br">
<head>
<meta charset="utf-8">
<title>Document</title>
</head>
<body>
<script>
window.addEventListener("contextmenu", function(event)
{
event.preventDefault();
});
</script>
</body>
</html>
The code on top of 4 lines is very simple, but it generated a doubt about the Event parameter (could be any parameter). When you create a parameter but do not define its value it is underfine correct ? in this case when I added the event contextmenu in the window and when this event occurs he will call an anonymous function cancelling the event contextmenu. But in this case it wouldn’t be like undefined.preventDefault() this parameter event has what value? and is referring to what ? would be a this ?
Then, in this case the Event parameter would be an object with various information contained in it ?
– Leandro Nascimento
Yes,
eventis an object with several properties, including the methodpreventDefaultthat you invoke. You can check all the properties of it here (remembering that he also inherits the properties of Event), or just make aconsole.login it.– Andre
So thank you very much @user140828 helped a lot!
– Leandro Nascimento