Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <!DOCTYPE html>
- <html lang="en">
- <head>
- <meta charset="UTF-8">
- <meta name="viewport" content="width=device-width, initial-scale=1.0">
- <title>Document</title>
- <style>
- .paused {
- background: #ddd;
- color: #555;
- }
- </style>
- </head>
- <body>
- <p id="log">Click on this document to give it focus.</p>
- <script>
- function pause() {
- document.body.classList.add("paused");
- log.textContent = "FOCUS LOST!";
- }
- function play() {
- document.body.classList.remove("paused");
- log.textContent =
- "This document has focus. Click outside the document to lose focus.";
- }
- let log = document.getElementById("log");
- window.addEventListener("blur", pause);
- window.addEventListener("focus", play);
- </script>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement