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

WBOY
WBOYOriginal
2016-05-16 17:20:591283browse
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.
Statement:
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