How to query string parameters in javascript_javascript skills
May 16, 2016 pm 04:17 PMThe example in this article describes the method of querying string parameters in javascript. Share it with everyone for your reference. The specific implementation method is as follows:
function getQueryStringArgs(){
//Get the query string and remove the question mark at the beginning
var qs = (location.search.length > 0 ? location.search.substring(1) : '');
//Object to save data
args = {};
//Get each item
var items = qs.length ? qs.split('&') : [],
item = null,
name = null,
//Use in for loop
i = 0, len = items.length;
//Add each item to the args object one by one
for(i = 0; i < len; i ){
Item = items[i].split('=');
name = decodeURIComponent(item[0]);
Value = decodeURIComponent(item[1]);
If(name.length){
args[name] = value; }
}
Return args;
}
I hope this article will be helpful to everyone’s JavaScript programming design.

Hot Article

Hot tools Tags

Hot Article

Hot Article Tags

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics

How to write a novel in the Tomato Free Novel app. Share the tutorial on how to write a novel in Tomato Novel.

How to recover deleted contacts on WeChat (simple tutorial tells you how to recover deleted contacts)

How to check your academic qualifications on Xuexin.com

12306 How to check historical ticket purchase records How to check historical ticket purchase records

The secret of hatching mobile dragon eggs is revealed (step by step to teach you how to successfully hatch mobile dragon eggs)

How to set font size on mobile phone (easily adjust font size on mobile phone)

The difference between Go language methods and functions and analysis of application scenarios

How to choose a mobile phone screen protector to protect your mobile phone screen (several key points and tips for purchasing mobile phone screen protectors)
