OLD | NEW |
---|---|
(Empty) | |
1 <html> | |
2 | |
3 <head><title>Possible BeforeUnload</title> | |
Charlie Reis
2016/03/29 18:33:21
Why "Possible"?
clamy
2016/03/30 13:31:11
Because the first version did not have the dialog
| |
4 <script> | |
5 function clickLink() { | |
6 var evt = document.createEvent("MouseEvents"); | |
7 evt.initMouseEvent("click", true, true, window, | |
8 0, 0, 0, 0, 0, false, false, | |
9 false, false, 0, null); | |
10 var target = document.getElementById("link"); | |
11 target.dispatchEvent(evt); | |
12 } | |
13 | |
14 function clickLinkSoon() { | |
Charlie Reis
2016/03/29 18:33:21
nit: Use consistent indent.
clamy
2016/03/30 13:31:11
Done.
| |
15 window.setTimeout(clickLink, 100); | |
16 return true; | |
17 } | |
18 | |
19 window.addEventListener("beforeunload", function(e){ | |
Charlie Reis
2016/03/29 18:33:21
nit: Space before {
clamy
2016/03/30 13:31:11
Done.
| |
20 var confirmationMessage = "foo"; | |
21 e.returnValue = confirmationMessage; | |
22 return confirmationMessage; | |
23 }); | |
Charlie Reis
2016/03/29 18:33:21
nit: 2 fewer spaces.
clamy
2016/03/30 13:31:11
Done.
| |
24 | |
25 </script> | |
26 </head> | |
27 | |
28 <a href="title2.html" id="link">link</a><br> | |
29 | |
30 </html> | |
OLD | NEW |