欢迎各位兄弟 发布技术文章

这里的技术是共享的

You are here

手机 html js 摇一摇 代码 有大用 有大大用

if (window.DeviceMotionEvent) {
	var liaotian = 0;
    var speed = 22;  //摇一摇程序,建议值在20-25之间;
    var x = y = z = lastX = lastY = lastZ = 0;  //默认值
    window.addEventListener('devicemotion', function() {
        var acceleration = event.accelerationIncludingGravity;
        x = acceleration.x;
        y = acceleration.y;
        if (Math.abs(x - lastX) > speed || Math.abs(y - lastY) > speed) {
            //window.location.href = 'http://pkt.zoosnet.net/LR/Chatpre.aspx?id=PKT40658297&lng=cn'  //摇动之后的行为,链接可以是报名、咨询、电话支持tel:+号码
            
			//window.location.href = 'http://pyt.zoosnet.net/LR/Chatpre.aspx?id=PYT58259775&lng=big5'; 
//目的是3秒内只摇一次,3秒后再摇的话,才起作用 if(liaotian == 0){ liaotian = 1; openZoosUrl(); window.setTimeout(function() { liaotian = 0; }, 3000); return false; } } lastX = x; lastY = y }, false) }


普通分类: