Home > Web Front-end > JS Tutorial > How to get the parameters after the question mark in the address bar using js_javascript skills

How to get the parameters after the question mark in the address bar using js_javascript skills

PHP中文网
Release: 2016-05-16 17:26:24
Original
1627 people have browsed it


Copy code The code is as follows:


$(document).ready(function () {
var url = window.location.search;
if (url.indexOf("?") != -1) {
var str = url.substr(1)
strs = str.split ("&");
for (i = 0; i < strs.length; i ) {
alert(strs.length);
alert(strs[i].split("=" )[0]);
alert(strs[i].split("=")[1]);
alert(strs[i].split("=")[0], '=' ,strs[i].split("=")[1], '
');
}
}
})


For example, above The address of strs.length is: 2, the value of strs[0].split("=")[0] is: tn; the value of strs[0].split("=")[1] is: list; the value of strs[1].split("=")[0] is: word; the value of strs[1].split("=")[1] is: liulan

Related labels:
source:php.cn
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
Latest Articles by Author
Latest Issues
Where is js written?
From 1970-01-01 08:00:00
0
0
0
js addClass not working
From 1970-01-01 08:00:00
0
0
0
js file code not found
From 1970-01-01 08:00:00
0
0
0
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template