js 获取浏览器url参数

一、获取浏览器地址url,并将url后的参数转化为数组。

var baseUrl = function GetRequest(url) { var theRequest = new Object(); if (url.indexOf("?") != -1) { str = url.split("?")[1]; strs = str.split("&"); for (var i = 0; i < strs.length; i++) { theRequest[strs[i].split("=")[0]] = (strs[i].split("=")[1]); } } return theRequest; } console.log(baseUrl(window.location.search))

  

原文地址:https://www.cnblogs.com/tiantianleyuan123/p/9305354.html