title: Javascript onload isn't working ("Uncaught TypeError: Cannot set property 'document.body' of null ")
body: <p>Here is my codes:</p>
  
  <p>Javascript:</p>
  
  <pre><code>document.body.onload = function() {
      function UP() {//Ẩn hiện nút UP
          if(window.pageYOffset &gt; window.innerHeight)
              document.getElementById('UP').style.display = "block";
      }
  }
  </code></pre>
  
  <p>HTML tag:</p>
  
  <pre><code>&lt;button id="UP" onclick="toTop(350);"&gt;&lt;/button&gt;
  </code></pre>
  
  <p>CSS style:</p>
  
  <pre><code>#UP {display: none;}
  </code></pre>
  
  <p>My idea is when I scroll down, then UP button will appear. But don't know why, it won't, it even return the error: "Uncaught TypeError: Cannot set property 'document.body' of null". Of couse, I did change other script like this:</p>
  
  <pre><code>function getReady() {
      UP();
  }
  function UP() {//Ẩn hiện nút UP
      if(window.pageYOffset &gt; window.innerHeight)
          document.getElementById('UP').style.display = "block";
  }
  </code></pre>
  
  <p>HTML tag:</p>
  
  <pre><code>&lt;body onload="getReady();"&gt;
      &lt;button id="UP" onclick="toTop(350);"&gt;&lt;/button&gt;
  &lt;/body&gt;
  </code></pre>
  
  <p>It is even more terrible. When I load site, I didn't see onload attr of body tag and the browser didn't return any error for me.</p>
  
  <p>Some other infomation:
  I develop on both side, Cr &amp; FF, it all says a same problem.
  And I'm working on Wordpress source.</p>