|
5 | 5 | <script src="../../stacktrace.js"></script>
|
6 | 6 | <script>
|
7 | 7 | /*window.onload = function() {
|
8 |
| - alert("window.onload"); |
9 |
| - }*/ |
10 |
| - |
| 8 | + alert("window.onload"); |
| 9 | + }*/ |
11 | 10 | window.onbeforeunload = function(e) {
|
12 | 11 | e = e || window.event;
|
13 |
| - // currentTarget originalTarget target |
| 12 | + // FF: currentTarget originalTarget target |
| 13 | + // Chrome: currentTarget srcElement target |
14 | 14 |
|
15 |
| - //alert("window.onbeforeunload"); |
16 | 15 | // capture stack trace
|
17 | 16 | // NOTE:
|
18 | 17 | // FF captures full stack,
|
19 | 18 | // IE captures stack but doesn't include 'onbeforeunload' function in stack,
|
20 |
| - // CHROME doesn't show stack |
21 |
| - var trace = printStackTrace(); |
22 |
| - alert('window.onbeforeunload stacktrace:\n\n' + trace.join('\n\n')); |
| 19 | + // CHROME doesn't show alert |
| 20 | + var trace = printStackTrace().join('\n\n'); |
| 21 | + document.getElementById("stacktrace").value = trace; |
| 22 | + alert('window.onbeforeunload stacktrace:\n\n' + trace); |
23 | 23 |
|
24 |
| - var msg = 'Do you want to continue window unload?'; |
| 24 | + var msg = 'Stacktrace:\n\n' + trace; |
25 | 25 | // For IE and Firefox prior to version 4
|
26 | 26 | if (e) {
|
27 | 27 | e.returnValue = msg;
|
|
50 | 50 | <li>Invoke the document.open method.</li>
|
51 | 51 | <li>Click the Back, Forward, Refresh, or Home button.</li>
|
52 | 52 | </ul>
|
| 53 | + <textarea id="stacktrace" style="width:100%; height:10em;">stacktrace</textarea> |
53 | 54 | </body>
|
54 | 55 | </html>
|
0 commit comments