title: Excute jquery if url is home page
body: <p>I need to fire piece of jQuery code only if it is home page.</p>
  
  <p>URL probability are</p>
  
  <pre><code>http://www.example.com
  http://www.example.com/
  http://www.example.com/default.aspx
  </code></pre>
  
  <p>How can i run code  if it is any of the above url i can use </p>
  
  <pre><code>var currenturl = window.location
  </code></pre>
  
  <p>but then i have to change this every time i move my code to server as on local host my url is like </p>
  
  <pre><code>http://localhost:90/virtualDir/default.aspx
  </code></pre>
  
  <p>in asp.net we can get the it using various </p>
  
  <p><code>HttpContext.Current.Request.Url.AbsolutePath</code>
   or 
  <code>HttpContext.Current.Request.ApplicationPath</code></p>
  
  <p>I am not sure what are the equivalent in jQuery</p>
  
  <p>reference of asp.net <a href="https://stackoverflow.com/questions/593709/how-to-get-the-url-of-the-current-page-in-c-sharp/16693496#16693496">example</a> </p>
  
  <p>UPDATE: </p>
  
  <p>I have taken a simple approach as i could not find other easy way of doing it</p>
  
  <pre><code>            var _href = $(location).attr('href').toLowerCase()
              var _option1 = 'http://localhost:51407/virtualDir/Default.aspx';
              var _option2 = 'http://www.example.com/Default.aspx';
              var _option3 = 'http://www.example.com/';
              if (_href == _option1.toLowerCase() || _href == _option2.toLowerCase() || _href == _option3.toLowerCase()) {
                  $(".bar-height").css("min-height", "689px");
                 // alert('aa');
              }
              else
              { //alert('bb'); }
  </code></pre>