This article mainly shares with you an article about JS getting url parameters and JS sending POST request method in json format. It has a good reference value and I hope it will be helpful to everyone. Let’s follow the editor to take a look, I hope it can help everyone.
<script type="text/javascript">
1. Get all parameter values of the url
function US() { var name, value; var str = location.href; var num = str.indexOf("?"); str = str.substr(num + 1); var arr = str.split("&"); for (var i = 0; i < arr.length; i++) { num = arr[i].indexOf("="); if (num > 0) { name = arr[i].substring(0, num); value = arr[i].substr(num + 1); this[name] = value; } } }
Related recommendations:
js extension examples for obtaining url parameters_javascript skills
Two ways for js to obtain url parameter values_javascript Tips
js Get URL Parameter Code Example Sharing (JS Operation URL)_javascript Tips
The above is the detailed content of How to get url parameters in JS. For more information, please follow other related articles on the PHP Chinese website!