js gets the spliced parameters behind the page url

Get the spliced ​​parameters behind the page url


1. Take the current page URL as an example to get articleId

https://editor.csdn.net/md?not_checkout=1&articleId=113110763

Insert picture description here
2. Method

function GetParam(paraName) {
    
    
				var url = document.location.toString();
				var arrObj = url.split("?");
				if (arrObj.length > 1) {
    
    
					var arrPara = arrObj[1].split("&");
					var arr;
					for (var i = 0; i < arrPara.length; i++) {
    
    
						arr = arrPara[i].split("=");
						if (arr != null && arr[0] == paraName) {
    
    
							return arr[1];
						}
					}
					return "";
				} else {
    
    
					return "";
		}
};

// 调用
var orgCode = GetParam("orgCode");

Guess you like

Origin blog.csdn.net/zcbmwasd/article/details/113110763