title: Detect whether a textbox is near the edge of the browser window
body: <p>I trying to create a check in JavaScript whether a textbox is near the edge of the browser window, say 200px.</p>
  
  <p>I have written a where I get the width of textbox and its offset.left and then compare to the width of the window, but I am not sure whether I am doing this correctly. </p>
  
  <p>Can someone please advise me how or what is the correct way? I need to do this for both left and right positions. </p>
  
  <pre><code> var textboxrightedge = $(e).width() + $(e).offset().left;
   var windowwidth = $(window).width();
  
   if( textboxrightedge - windowwidth &gt; $(e).width())
   //do something
  </code></pre>
  
  <p>This is what I have written for right hand edge. I am not sure for the left, and equally I cannot get it to test if the box is in 200px. I need to check if the browser window is very small.</p>