欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  IT编程

PhoneGap-----Accelerometer

程序员文章站 2022-05-17 23:43:01
everything in the code!!!! [html]     acce...</div> <div class="content"> <p>everything in the code!!!!</p> <p><br> [html]<br> <!doctype html> <br> <head> <br> <title>acceleration example</title> <br> <script type="text/javascript" charset="utf-8" src="cordova.js"></script> <br> <script type="text/javascript" charset="utf-8"> <br>     var watchid = null; <br>     document.addeventlistener("deviceready",ondeviceready,false); <br>      <br>     function ondeviceready() <br>     { <br>         startwatch(); <br>     } <br>      <br>     function startwatch() <br>     { <br>         var options = {frequency:3000}; <br>         watchid = navigator.accelerometer.watchacceleration(onsuccess,onerror,options); <br>     } <br>      <br>     function stopwatch() <br>     { <br>         if(watchid) <br>         { <br>             navigator.accelerometer.clearwatch(watchid); <br>             watchid = null; <br>         } <br>     } <br>      <br>     function onsuccess(acceleration) <br>     { <br>         var element = document.getelementbyid('accelerometer'); <br>         element.innerhtml = 'acceleration x: ' + acceleration.x + '<br />' + <br>                             'acceleration y: ' + acceleration.y + '<br />' + <br>                             'acceleration z: ' + acceleration.z + '<br />' + <br>                             'timestamp: '      + acceleration.timestamp + '<br />'; <br>     } <br>      <br>     function onerror() <br>     { <br>         alert('oooops!'); <br>     } <br>      <br> </script> <br> </head> <br> <body> <br>     <p id="accelerometer">waiting for accelerometer...</p> <br>     <button onclick="stopwatch();">stop watching</button> <br> </body> <br> </html> </p> <p><!doctype html><br> <head><br> <title>acceleration example</title><br> <script type="text/javascript" charset="utf-8" src="cordova.js"></script><br> <script type="text/javascript" charset="utf-8"><br>     var watchid = null;<br>  document.addeventlistener("deviceready",ondeviceready,false);<br>  <br>  function ondeviceready()<br>  {<br>   startwatch();<br>  }<br>  <br>  function startwatch()<br>  {<br>   var options = {frequency:3000};<br>   watchid = navigator.accelerometer.watchacceleration(onsuccess,onerror,options);<br>  }<br>  <br>  function stopwatch()<br>  {<br>   if(watchid)<br>   {<br>    navigator.accelerometer.clearwatch(watchid);<br>    watchid = null;<br>   }<br>  }<br>  <br>  function onsuccess(acceleration)<br>  {<br>   var element = document.getelementbyid('accelerometer');<br>   element.innerhtml = 'acceleration x: ' + acceleration.x + '<br />' +<br>                       'acceleration y: ' + acceleration.y + '<br />' +<br>        'acceleration z: ' + acceleration.z + '<br />' +<br>        'timestamp: '      + acceleration.timestamp + '<br />';<br>  }<br>  <br>  function onerror()<br>  {<br>   alert('oooops!');<br>  }<br>  <br> </script><br> </head><br> <body><br>     <p id="accelerometer">waiting for accelerometer...</p><br>     <button onclick="stopwatch();">stop watching</button><br> </body><br> </html></p> <p><br>  </p> </div> <div class="info-pre-next"> <p> 上一篇: <a href="/article/1033273.html"> Laravel认证原理以及完全自定义认证详解 </a> </p> <p> 下一篇: <a href="/article/1033275.html"> Django中datetime的处理方法(strftime/strptime) </a> </p> </div> <div class="wz_tuijian"> <p> 推荐阅读 </p> <ul> <li> <a href="/article/1980993.html" target="_blank" title="PhoneGap-----Accelerometer"> <h2> PhoneGap-----Accelerometer </h2> </a> </li> <li> <a href="/article/1033274.html" target="_blank" title="PhoneGap-----Accelerometer"> <h2> PhoneGap-----Accelerometer </h2> </a> </li> </ul> </div> </article> </div> </main> <footer><div class="box"><div class="ft_nav"><div class="ft_about"><p>关于网站</p><ul><li><a href="/sitemap.xml" target="_blank" title="网站地图">网站地图</a></li><li><a href="/list/2/" title="最新程序员文章站">最新程序员文章站</a></li></ul></div><div class="ft_contact"><ul><li>本站所有数据收集于网络如有侵犯到您的权益,请联系我们进行下架处理。</li><li class="email_show"></li></ul></div></div><div class="copyright"><div class="cr_left"><p> 备案号:<a href="https://beian.miit.gov.cn/#/Integrated/index" target="_blank">粤ICP备20058927号</a></p><p>© Copyright © 2020-2022 www.superweb999.com 程序员文章站. </p></div></div></div></footer> </body> </html>