manual-005.html (532B)
1 <!doctype html> 2 <title>Event loop pause for beforeunload</title> 3 <script> 4 var counter = 0; 5 6 onload = function count() { 7 document.getElementById("log").textContent = counter++ 8 setTimeout(count, 200); 9 } 10 11 addEventListener("beforeunload", 12 function(e) { 13 e.preventDefault() 14 }, 15 false); 16 </script> 17 <ul> 18 <li>Click on the link below. When the prompt appears the counter at the bottom must stop incrementing. 19 <li>Opt not to leave the page. The counter must start incrementing again 20 </ul> 21 <p><a href="">Click here</a> 22 <div id="log"></div>