Home > Web Front-end > JS Tutorial > body text

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
1580 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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template