title: How to find the filename without the extension through JQuery
body: <p>I am hoping to find only the filename within the current page URL.</p>
  
  <p>So if the URL is</p>
  
  <pre><code>www.ex.com/des/filename.php
  </code></pre>
  
  <p>or</p>
  
  <pre><code>www.ex.com/des/filename.php#9
  </code></pre>
  
  <p>I need to get only</p>
  
  <pre><code>filename
  </code></pre>
  
  <p>I tried this, but it doesn't work.</p>
  
  <pre><code>var loc = window.location;
  var fileNameIndex = loc.lastIndexOf("/") + 1;
  var output = loc.substr(0, loc.lastIndexOf('.')) || loc;
  </code></pre>
  
  <p>Thanks</p>