1

JS gets the content before the last slash in the URL

var url = window.location.href; 
var index = url.lastIndexOf("\/"); 
str = url.substring(0,index+1); 
console.log(str); // http://www.mywlaq.cn/archives/

JS gets the content after the last slash in the URL

var url = window.location.href;
var index = url.lastIndexOf("\/");
str = url.substring(index + 1,url.length); console.log(str); // 3390.html

墨城
1.7k 声望2.1k 粉丝

« 上一篇
js算法