W3C确定了控制设备震动的API:http://www.w3.org/TR/vibration/
W3C给的定义:
This specification defines an API that provides access to the vibration mechanism of the hosting device. Vibration is a form of tactile feedback.
诶呦,不错哦,这个可以用来开发很多有趣的应用,《爆裂左手》《爆裂右手》之类。
Demo 都有了:
<script>
navigator.vibrate = navigator.vibrate || navigator.webkitVibrate || navigator.mozVibrate || navigator.msVibrate;
if (navigator.vibrate) {
while(1) {
navigator.vibrate([200, 100, 200]); //震 100ms, 停 100ms, 再震 200ms:
}
}
</script>
插到页面里,然后拿手机访问试试吧。