赞
踩
//if phone support navigator.vibrate
if (navigator.vibrate) {
//vibrate 1 second
navigator.vibrate(1000);
} else if (navigator.webkitVibrate) {
navigator.webkitVibrate(1000);
}
index.html 实现调用shake.js和实现手机震动的功能:
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="initial-scale=1.0, width=device-width, user-scalable=no" />
<meta name="apple-mobile-web-app-capable" content="yes" />
<title>Shake.js</title>
<style type="text/css">
body {
background: #E9E9E9;
color: #333;
font: 1em/1.3em "Helvetica Neue", Helvetica, Arial, Verdana, sans-serif; /* 16px / 21px */
text-shadow: rgba(255,255,255,0.8) 0 1px 0;
text-align: center;
}
</style>
<
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。