title: How to activate different functions if you are at certain part of the page?
body: <p>I want to make two functions, &quot;functionattoppage&quot; and &quot;functionat1000pxpage&quot;. I want to make the function &quot;functionattoppage&quot; activate when the user is at the top of a webpage and &quot;functionat1000pxpage&quot; activate when the user is down about 1000px from the top of the page, is this possible?</p>
  <p>Here is the only thing I could come up with:</p>
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>window.onscroll = function () {
    scrollFunction()
  };
  
  function scrollFunction() {
    if (document.body.scrollTop &gt; 1000 || document.documentElement.scrollTop &gt; 1000) {
        document.body.classList.add("body.changed");
    }
    
    if (document.body.scrollTop &gt; 0 || document.documentElement.scrollTop &gt; 0) {
        document.body.classList.remove("body.changed");
    }
  }</code></pre>
  <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;h1&gt;Please look at the JavaScript section, it is what my best guess would be on how to make this work&lt;/h1&gt;</code></pre>
  </div>
  </div>
  </p>
  <p>Sorry if I didn't explain this very well, I don't have much time right now. If you need more information please ask me.</p>