jquery获取url最后一个斜杠前、后的内容
1.js
$(function() {
// content css3
var htmlHref = window.location.href;
htmlHref = htmlHref.replace(/^http:\/\/[^/]+/, "");
var addr = htmlHref.substr(htmlHref.lastIndexOf('/', htmlHref.lastIndexOf('/') - 1) + 1);
var index = addr.lastIndexOf("\/");
//js 获取字符串中最后一个斜杠后面的内容
var addrLast = decodeURI(addr.substring(index + 1, addr.length));
//js 获取字符串中最后一个斜杠前面的内容
var str = decodeURI(addr.substring(0, index));
console.log(addrLast+ " " +str);
});
即使有汉字也会解析出来
效果: