我有一个网站网址:
http://web-demo.com/admin/dashboard
http://web-demo.com/web-demo.com/node/14/edit
var pathArray = window.location.pathname.split( '/' );
var sName = pathArray[0];
var rName;
现在,我可以获得sName ='web-demo.com'。我需要
rName = admin / dashboard;
rName = web-demo.com/node/add/page;
rName = web-demo.com/node/14/edit;
如何使用jquery完成此操作?请帮忙。
答案 0 :(得分:0)
试试这个:
var x = "http://web-demo.com/web-demo.com/node/14/edit";
var pathArray = x.split( '/' );
var result = new Array();
alert(pathArray.slice(2).join('/'));