//Shake a shake varShake_threshold = 1600; varlast_update = 0; varx = y = z = last_x = last_y = last_z = 0; if(window. Devicemotionevent) {Window.addeventlistener (' Devicemotion ', Devicemotionhandler,false); } Else{alert (' This device does not support shaking events '); } functionDevicemotionhandler (eventData) {varAcceleration =eventdata.accelerationincludinggravity; varCurtime =NewDate (). GetTime (); if((curtime-last_update) > 100) { varDifftime = Curtime-last_update; Last_update=Curtime; X=acceleration.x; Y=ACCELERATION.Y; Z=acceleration.z; varSpeed = Math.Abs (x + y + z-last_x-last_y-last_z)/difftime * 10000; varStatus = document.getElementById ("status"); if(Speed >shake_threshold) {OPENSWT (); } last_x=x; Last_y=y; Last_z=Z; } } //function Doresult () { //window.location.href = "Tel:";} functionOPENSWT () {window.location.href = "/call.html";} document.write (' <div style= ' position:fixed;top:2%;right:0px;width:55px;z-index:10000; ><a href= "javascript:getswt (\ ' yao\ ');" ></a></div>");
The phone shakes a shake into a page _js code