Add or Subtracting into $(window).scrollTop + $(window).height == $(document).height() - Scrolled to bottom of page equation
<p>I'm running an if function when the user gets to the bottom of the page which works great as is like this</p>

<pre><code>if($(window).scrollTop() + $(window).height() == $(document).height()) {}
</code></pre>

<p>However I want it to run slightly before the bottom - about 300px before. </p>

<p>I've tried</p>

<pre><code>if($(window).scrollTop() + $(window).height() + 300 == $(document).height()) {}
</code></pre>

<p>AND</p>

<pre><code>if($(window).scrollTop() + $(window).height() == $(document).height() -300) {}
</code></pre>

<p>and all other variations to no avail.</p>

<p>I've also tried putting variables in.</p>

<pre><code>var plusheight = 300;

if($(window).scrollTop() + $(window).height() + plusheight == $(document).height()) {}
if($(window).scrollTop() + $(window).height() + $plusheight == $(document).height()) {}
if($(window).scrollTop() + $(window).height() + "plusheight" == $(document).height()) {}
</code></pre>

<p>What am I doing wrong?</p>
