Home > Web Front-end > JS Tutorial > js method to get URL parameters (getQueryString) example_javascript skills

js method to get URL parameters (getQueryString) example_javascript skills

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Release: 2016-05-16 17:20:59
Original
1326 people have browsed it
Copy code The code is as follows:

function getQueryString(name) {
var reg = new RegExp( "(^|&)" name "=([^&]*)(&|$)", "i");
var r = location.search.substr(1).match(reg);
if (r != null) return unescape(decodeURI(r[2])); return null;
}

This method returns string

by default If it is an int type, it needs to be converted when using JS, such as using the parseInt(value) function.
Related labels:
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template