摇一摇!
<!DOCTYPE html><html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<title>Examples</title>
<meta name="description" content="">
<meta name="keywords" content="">
<link href="" rel="stylesheet">
<script src="cordova.js"></script>
<script>
document.addEventListener('deviceready', deviceready, false);
function deviceready(){
startWatch();
}
function startWatch(){
navigator.accelerometer.watchAcceleration(function(msg){
if(Math.abs(msg.x) >14 || Math.abs(msg.y) >14 || Math.abs(msg.z) >14){
navigator.notification.beep(1);
}
},function(){},{frequency: 500});
}
</script>
</head>
<body>
</body>
</html>
像我这样判断用户有没有摇手机科学么???有没有跟好的写法!
{:4_86:} 能获取手机感应器的话应该就可以摇一摇。
页:
[1]