(Javascript) How to extract the last part of the current URL - without the file extension? -
i have following javascript code working:
<script type="text/javascript"> urlpath=window.location.pathname; urlpatharray = urlpath.split('/'); urlpath1=urlpatharray[2]; document.write('<a href="http://www.example.com/contact.php?id='+urlpath1+'">test</a>'); </script> lets current url http://www.example.com/products/0033.htm
the javascript produces hyperlink http://www.example.com/contact.php?id=0033.htm
how modify script urlpath1 , eventual hyperlink without ".htm" part?
do did filename, split on . instead of / , take first piece.
Comments
Post a Comment