javascript - How to intercept the parameters behind the url
曾经蜡笔没有小新
曾经蜡笔没有小新 2017-05-19 10:09:16
0
5
478

I want to intercept the three groups of numbers after the id and then splice them into a string

http://localhost/360buji/Toni...

曾经蜡笔没有小新
曾经蜡笔没有小新

reply all(5)
刘奇
var href = window.location.href,
    str = href.substring(href.indexOf("#")+1),
    reg = /([^&#?=]+)=(\w*)/g,
    result = [];
    
str.replace(reg,function(str,key,val){
    result = val.split("&");
    return str;
});
    

This should be fine

阿神

var list = location.href.split('id=')[1].split('&')

Ty80

var str = location.href.split("=")[1].split("&");
console.log(str[0]+str[1]+str[2]);

仅有的幸福

linkPar:function(key,v){//url value: key name, string

v = v?v:location.href;
return (v.match(new RegExp("(?:\?|&)"+key+"=(.*?)(?=&|$)"))||['',null])[1];  

}

淡淡烟草味

//Get url parameters
function getUrlParam(name) {

 var reg = new RegExp("(^|&)"+ name +"=([^&]*)(&|$)");
 var r = window.location.search.substr(1).match(reg);
 if(r!=null)return  unescape(r[2]); return null;    

}

var personName = decodeURI(decodeURI(getUrlParam('personName')));//中文url参数
var userNo = getUrlParam('userNo');//普通url参数
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template