Is event object and window.event object the same ?

Hello guys, sorry to disturb you, can someone explain what is the difference between an event object passed by an event handler and an a window event please. I just read that the window.event was used for backward compatibility like this: event = event || window.event I don't understand, event and window.event aren't the same thing ? for e,g consider the following:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Event vs window.event</title>
</head>
<body>
<button id="clickMe">Click Me</button>
<input id="typeHere" placeholder="Type something here" />
<script>
// Click Event Listener
document.getElementById("clickMe").addEventListener("click", (event) => {
console.log("---- Click Event ----");
console.log("event (local):", event);
console.log("window.event (global):", window.event);
});

// Input Event Listener
document.getElementById("typeHere").addEventListener("input", (event) => {
console.log("---- Input Event ----");
console.log("event (local):", event);
console.log("window.event (global):", window.event);
});
</script>
</body>
</html>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Event vs window.event</title>
</head>
<body>
<button id="clickMe">Click Me</button>
<input id="typeHere" placeholder="Type something here" />
<script>
// Click Event Listener
document.getElementById("clickMe").addEventListener("click", (event) => {
console.log("---- Click Event ----");
console.log("event (local):", event);
console.log("window.event (global):", window.event);
});

// Input Event Listener
document.getElementById("typeHere").addEventListener("input", (event) => {
console.log("---- Input Event ----");
console.log("event (local):", event);
console.log("window.event (global):", window.event);
});
</script>
</body>
</html>
I didn't really understand what is the difference
0 Replies
No replies yetBe the first to reply to this messageJoin
Want results from more Discord servers?
Add your server