title: Why window onscroll event does not work?
body: <p>I want to execute the window <code>onscroll</code> event, but I don't know why it doesn't work on all browsers(firefox, chrome, etc), and there is no errors occurred.  </p>
  
  <p><strong>Full code:</strong>
  <div class="snippet" data-lang="js" data-hide="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>var elem = document.getElementById('repeat');
  var show = document.getElementById('show');
  
  for (i = 1; i &lt;= 300; i++) {
      elem.innerHTML += i + "&lt;br/&gt;";
  }
  
  
  window.onscroll = function () {
      show.innerHTML = document.body.scrollTop;
  };</code></pre>
  <pre class="snippet-code-css lang-css prettyprint-override"><code>#show {
      display:block;
      position:fixed;
      top:0px;
      left:300px;
  }</code></pre>
  <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;pre id="repeat"&gt;&lt;/pre&gt;
  
  &lt;div style="position:relative;"&gt;
      &lt;div id="show"&gt;x&lt;/div&gt;
  &lt;/div&gt;</code></pre>
  </div>
  </div>
  </p>
  
  <p>Also jsfiddle:
  <a href="http://jsfiddle.net/sqo0140j" rel="noreferrer">http://jsfiddle.net/sqo0140j</a></p>
  
  <p><strong>What is the problem ?</strong></p>