scrollTop stuck at zero
<p>I am trying to get the vertical position on scroll of page but it is stuck at <code>0</code> value.</p>

<pre><code>window.onscroll=f;
function f() {

document.getElementById('div1').innerHTML=document.body.scrollTop;
}
</code></pre>
