<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>window_location_search</title>
<script>
window.onload = function(){
var oBody = document.getElementById('body1');
var sData = window.location.search;
//获取浏览器参数, 网址后?后面所缀参数.
alert(sData);
var sHash = window.location.hash;
// 获取url哈希表, 网址后#后面内容;
alert(sHash);
iNum01 = sData.split("=")[1];
// alert(iNum01);
if (iNum01 == 1) {
oBody.style.backgroundColor = 'lightgreen';
}
else if (iNum01 == 2) {
oBody.style.backgroundColor = 'orchid';
}
else {
oBody.style.backgroundColor = 'silver';
}
}
</script>
</head>
<body id="body1">
<h1>页面</h1>
</body>
</html>