Posted in Javascript onMarch 09, 2021
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>JavaScript获取Url参数</title>
<script src="1111.js?a=123&b=456" id='jsid'></script>
<script type="text/javascript">
function getParam() {
var url = document.getElementById('jsid').getAttribute('src');
var param = new Array();
if (url.indexOf("?") != -1) {
var str = url.substr(1);
strs = str.split("&");
for(var i = 0; i < strs.length; i ++) {
param[strs[i].split("=")[0]]=unescape(strs[i].split("=")[1]);
}
}
console.log( param );
}
getParam();
</script>
</head>
<body>
</body>
</html>
JS JavaScript获取Url参数,src属性参数
声明:登载此文出于传递更多信息之目的,并不意味着赞同其观点或证实其描述。
Reply on: @reply_date@
@reply_contents@