HTML5 手机甩出Web 网页背景色

清华大佬耗费三个月吐血整理的几百G的资源,免费分享!....>>>

<!doctype html>
<html>
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width,initial-scale=1.0"/>
<title>HTML5 手机摇一摇</title>
<script type="text/javascript">
var color = new Array('#fff', '#ff0', '#f00', '#000', '#00f', '#0ff');
if(window.DeviceMotionEvent) {
	var speed = 25;
	var x = y = z = lastX = lastY = lastZ = 0;
	window.addEventListener('devicemotion', function(){
		var acceleration =event.accelerationIncludingGravity;
		x = acceleration.x;
		y = acceleration.y;
		if(Math.abs(x-lastX) > speed || Math.abs(y-lastY) > speed) {
			document.body.style.backgroundColor = color[Math.round(Math.random()*10)%6];
		}
		lastX = x;
		lastY = y;
	}, false);
}
</script>
</head>
<body>
HTML 5 手机摇一摇
</body>
</html>