The js gets the parameter code in the url as shown below. The code is simple and easy to understand and has comments attached. Please forgive me if I don’t write well!
function UrlSearch() {var name, value;var str = location.href; //Get the entire address bar var num = str.indexOf("?")str = str.substr(num + 1); //Get all parameters stringvar.substr(start [, length ]var arr = str.split("&"); //Put each parameter in the array 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;}}}Example
//The link to jump to the page url: contextPath+"/page4nui/ci2k3/prreportcheckmngt/report_check.jsp?ciPrId="+ciPrId//The page you jump to is var url = new UrlSearch();ciPrId = url.ciPrId;
That's the end. . The knowledge of obtaining url parameters by js is very practical. I hope everyone can understand it thoroughly and thoroughly!
The above is the example code of JS acquisition parameter in url introduced by the editor. I hope it will be helpful to everyone. If you have any questions, please leave me a message and the editor will reply to everyone in time. Thank you very much for your support to Wulin.com website!