js获取路由(http://www.aaa.com/module/218.html)中的id

//返回当前页面的 URL(http://www.aaa.com/模块名/216.html)
 var strUrl = window.location.href;
//把一个字符串按照/分割成字符串数组 array['http:','www.aaa.com','模块名','216.html']
 var arrUrl = strUrl.split("/");
 //获取216.html
 var strPage = arrUrl[arrUrl.length-1];
 //获取数值(26)
 var id=strPage.replace(/[^0-9]/ig,"");
 

猜你喜欢

转载自blog.csdn.net/qq_40012791/article/details/79984811