ShadowIce
06-03-2009, 03:59 PM
Hi all, I've been doing some research on url names. The problem is, I need this code to return like say "index.php", it would return "index". But idk where I went wrong..
Anyway..
The code:
<script>
var sPage;
var sPath = window.location.pathname;
//var sPage = sPath.substring(sPath.lastIndexOf('\\') + 1);
//var sPage = sPath.substring(sPath.lastIndexOf('/') + 1);
if(sPath.substring(sPath.lastIndexOf('.') + 1)){
sPage=sPath.split("",3);
}
sPage = sPath.substring(sPath.lastIndexOf('/') + 1);
alert(sPage);
</script>
ANY help is GREATLY appreciated! :)
~SI~
Anyway..
The code:
<script>
var sPage;
var sPath = window.location.pathname;
//var sPage = sPath.substring(sPath.lastIndexOf('\\') + 1);
//var sPage = sPath.substring(sPath.lastIndexOf('/') + 1);
if(sPath.substring(sPath.lastIndexOf('.') + 1)){
sPage=sPath.split("",3);
}
sPage = sPath.substring(sPath.lastIndexOf('/') + 1);
alert(sPage);
</script>
ANY help is GREATLY appreciated! :)
~SI~