For example, the URL is
http://ttweb.xxxx.com/finance/index.php?r=index/index#report/channelMonthly&cid=17&startT=1509494400 &ostype=1
Need to get? After all the parameters, the code is as follows:
function getqueryvariable () { var query = window.document.location.href.toString (); http://ttweb.xxxx.com/finance/index.php?r=index/index#report/channelMonthly&cid=17&startT=1509494400 &ostype=1 var query = Query.split ("?"); Question mark split URL [' http://ttweb.xxxx.com/finance/index.php ', ' r=index/index#report/channelmonthly&cid=17&startt= 1509494400&ostype=1 '] var vars = Query[1].split ("&");//The array index is a value of 1 (r=index/index#report/channelmonthly &cid=17&startt=1509494400&ostype=1) divided by &, the result is (["r=index/index#report/channelmonthly", "cid=17", "startt=1509494400", "ostype=1"]) var res = []; for (Var i=0;i<vars.length;i++) { var pair = vars[i].split ("="); Res[pair[0]] = pair[1]; } return res; } Console.log (Getqueryvariable ())
JS Get Get Parameters