title: window.pageYOffset not working in if loop
body: <p>I am using the following kind of code and i dont know why this is not working</p>
  
  <pre><code>window.onload = function (){
     if(window.pageYOffset &gt;= 10){
        alert("pageYOffset: " + window.pageYOffset)
     }
  }
  </code></pre>
  
  <p>By not working i mean that the alert box is not prompted</p>
  
  <p>Is there a way to activate the function on scrolling instead of me doing it onload using <strong>Pure Javascript</strong></p>