OLD | NEW |
| 1 var fileXHREnabled = function() { |
| 2 var xhr = new XMLHttpRequest(); |
| 3 try { |
| 4 xhr.onreadystatechange = function() {}; |
| 5 xhr.onerror = function() {}; |
| 6 xhr.open("GET", "nothing.xml", true); |
| 7 xhr.send(null); |
| 8 } catch (e) { |
| 9 return false; |
| 10 } |
| 11 |
| 12 xhr.abort(); |
| 13 return true; |
| 14 }(); |
| 15 |
1 // Regenerate page if we are passed the "?regenerate" search param | 16 // Regenerate page if we are passed the "?regenerate" search param |
2 // or if the user-agent is chrome AND the document is being served | 17 // or if the user-agent is chrome AND the document is being served |
3 // from the file:/// scheme. | 18 // from the file:/// scheme. |
4 if (window.location.search == "?regenerate" || | 19 if (window.location.search == "?regenerate" || |
5 (navigator.userAgent.indexOf("Chrome") > -1) && | 20 (navigator.userAgent.indexOf("Chrome") > -1) && |
6 (window.location.href.match("^file:"))) { | 21 (window.location.href.match("^file:")) && |
| 22 fileXHREnabled) { |
7 | 23 |
8 // Hide body content initially to minimize flashing. | 24 // Hide body content initially to minimize flashing. |
9 document.write('<style id="hider" type="text/css">'); | 25 document.write('<style id="hider" type="text/css">'); |
10 document.write('body { display:none!important; }'); | 26 document.write('body { display:none!important; }'); |
11 document.write('</style>'); | 27 document.write('</style>'); |
12 | 28 |
13 window.onload = window.renderPage; | 29 window.onload = window.renderPage; |
14 | 30 |
15 window.postRender = function() { | 31 window.postRender = function() { |
16 var elm = document.getElementById("hider"); | 32 var elm = document.getElementById("hider"); |
17 elm.parentNode.removeChild(elm); | 33 elm.parentNode.removeChild(elm); |
18 | 34 |
19 // Since populating the page is done asynchronously, the DOM doesn't exist | 35 // Since populating the page is done asynchronously, the DOM doesn't exist |
20 // when the browser tries to resolve any #anchors in the URL. So we reset | 36 // when the browser tries to resolve any #anchors in the URL. So we reset |
21 // the URL once we're done, which forces the browser to scroll to the anchor | 37 // the URL once we're done, which forces the browser to scroll to the anchor |
22 // as it normally would. | 38 // as it normally would. |
23 if (location.hash.length > 1) | 39 if (location.hash.length > 1) |
24 location.href = location.href; | 40 location.href = location.href; |
25 } | 41 } |
| 42 } else if ((navigator.userAgent.indexOf("Chrome") > -1) && |
| 43 (window.location.href.match("^file:")) && |
| 44 !fileXHREnabled) { |
| 45 window.onload = function() { |
| 46 // Display the warning to use the --allow-file-access-from-files. |
| 47 document.getElementById("devModeWarning").style.display = "block"; |
| 48 } |
26 } | 49 } |
OLD | NEW |