summaryrefslogtreecommitdiffstats
path: root/chrome/common/extensions/docs/js/bootstrap.js
blob: 7741df062d465120f993621ae1c96423dd618988 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
// Regenerate page if we are passed the "?regenerate" search param
// or if the user-agent is chrome AND the document is being served
// from the file:/// scheme.
if (window.location.search == "?regenerate" ||
    (navigator.userAgent.indexOf("Chrome") > -1) &&
    (window.location.href.match("^file:")))    {
  
  // Hide body content initially to minimize flashing.
  document.write('<style id="hider" type="text/css">');
  document.write('body { display:none!important; }');
  document.write('</style>');

  window.onload = window.renderPage;

  window.postRender = function() {
    var elm = document.getElementById("hider");
    elm.parentNode.removeChild(elm);

    // Since populating the page is done asynchronously, the DOM doesn't exist
    // when the browser tries to resolve any #anchors in the URL. So we reset
    // the URL once we're done, which forces the browser to scroll to the anchor
    // as it normally would.
    if (location.hash.length > 1)
      location.href = location.href;
  }
}