日期:2014-05-16 浏览次数:20309 次
var pathName=window.document.location.pathname;
var projectName=pathName.substring(0,pathName.substr(1).indexOf('/')+1);
return projectName;
<script type="text/javascript">
var str="http://127.0.0.1/Pad/";
var arr=str.split("/");
alert(arr[arr.length-2]);
</script>
var str = 'http://127.0.0.1/Pad/';
var result = str.match(/^http:\/\/.*\/(.*?)\//);
console.log(result[1]);