title: (Javascript) How to extract the last part of the current URL - without the file extension?
body: <p>I currently have the following javascript code working:</p>
  
  <pre><code>&lt;script type="text/javascript"&gt; 
      urlPath=window.location.pathname; 
      urlPathArray = urlPath.split('/'); 
      urlPath1=urlPathArray[2]; 
      document.write('&lt;a href="http://www.example.com/contact.php?id='+urlPath1+'"&gt;test&lt;/a&gt;'); 
      &lt;/script&gt; 
  </code></pre>
  
  <p>Lets say the current URL is <code>http://www.example.com/products/0033.htm</code></p>
  
  <p>The javascript produces a hyperlink to <code>http://www.example.com/contact.php?id=0033.htm</code></p>
  
  <p>How do I modify this script so that <em>urlPath1</em> and the eventual hyperlink is without the ".htm" part?</p>