1// JavaScript Document 2//var button = document.querySelector(".exit-button"); use if in body content section 3 4function handleDomContent() { 5 6 var button = document.querySelector(".exit-button"); 7 var NEW_CURRENT_PAGE_URL = "https://google.com"; 8 var NEW_TAB_URL = "https://weather.com"; 9 10 function handleExit() { 11 window.open(NEW_TAB_URL, "_blank"); 12 window.location.replace(NEW_CURRENT_PAGE_URL); 13 } 14 15 button.addEventListener("click", handleExit); 16 17 // Start escape key 18 window.addEventListener('keydown', function (evt) { 19 evt = evt || window.event; 20 var isEscape = false; 21 if ("key" in evt) { 22 isEscape = (evt.key === "Escape" || evt.key === "Esc"); 23 } else { 24 isEscape = (evt.keyCode === 27); 25 } 26 if (isEscape) { 27 window.open(NEW_TAB_URL, "_blank"); 28 window.location.replace(NEW_CURRENT_PAGE_URL); 29 30 if (evt) { 31 // stop escape from cancelling redirect 32 evt.preventDefault(); 33 34 // early IEs don't have preventDefault 35 evt.returnValue = false; 36 } 37 38 return false; 39 } 40 }); 41 // end escape key 42 43} 44window.addEventListener("DOMContentLoaded", handleDomContent)
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.