On the Internet to read some articles on this issue, are said not clear, some is a mess, completely unable to see, so found a can use, reference as a note.
First get the Address bar information to the current page var url = window.location.href;//Get the URL address var obj = {};//The object to be used to hold the parameter var reg =/\?/; intercept if (Url.match ( REG) { //To determine incoming parameters, to intercept with question marks, after the question mark is the parameter var chars = Url.split ('? ') [1]; var arr = chars.split (' & ');//Intercept & //Get truncated array as key value pair string for (var i = 0; i < arr.length; i++) { //Conservative point OK See if the Name=value form is var num = arr[i].indexof ("="); if (num > 0) { //concatenation string var name = arr[i].substring (0, num); var value = arr[i].substr (num + 1); Splicing object, and transcoding obj[decodeuricomponent (name)] = decodeuricomponent (value);}}} Console.log (obj);
So you can use it.
js get the current URL address parameter Chinese garbled problem