获取浏览器路径'?'开头,&开头的参数

js

	var href='http://localhost:8083/datas/dataflow/logicJob?id=CMZJJO2100000001&type=proLook'
				var urlParams = (function(url){
					var result = new Object();
					var idx = url.lastIndexOf('?');
					if (idx > 0){
						var params = url.substring(idx + 1).split('&');
						for (var i = 0; i < params.length; i++){
							idx = params[i].indexOf('=');
							if (idx > 0){
								result[params[i].substring(0, idx)] = params[i].substring(idx + 1);
							}
						}
					}
					return result;
				})(href);
				console.log('urlParams',urlParams)
				/*urlParams={
					id: "CMZJJO2100000001",
					type: "proLook"
				 };*/
posted @ 2021-06-24 17:11  Empress&  阅读(485)  评论(0编辑  收藏  举报