Posted in Javascript onMarch 04, 2017
Parse:
function getParam() { var param = new Object() var item = new Array(); if (location.search == "") { return param; }; var query = location.search.substring(1); var list = query.split('&'); for(var i = 0; i < list.length; i++) { item = list[i].split('='); if (typeof param[item[0]] == "undefined") { param[item[0]] = new Array(); } param[item[0]].push(item[1]); }; return param; };
Build:
function getUrlByParam(param) { var url = ""; for (field in param) { for (index in param[field]) { url += "&" + field + "=" + param[field][index]; }; }; return url == "" ? url : url.substring(1); };
以上这篇浅谈javascript的url参数parse和build函数就是小编分享给大家的全部内容了,希望能给大家一个参考,也希望大家多多支持三水点靠木。
浅谈javascript的url参数parse和build函数
- Author -
jingxian声明:登载此文出于传递更多信息之目的,并不意味着赞同其观点或证实其描述。
Reply on: @reply_date@
@reply_contents@