简短的运动器材检查评定PHP脚本代码,检查评定

作者: 韦德国际1946国际网址  发布:2019-05-28

github地址:

// 检测iphone设备
if (/ipad|iphone|mac/i.test(navigator.userAgent)){
    console.log("apple device");
}

// 检测android设备
if (/android/i.test(navigator.userAgent.toLowerCase())){
    console.log("android");
}

// 检测微信环境
if ((/micromessenger/i.test(navigator.userAgent.toLowerCase()))) {
    console.log("微信");
}

// 检测移动设备
if (/iphone|nokia|sony|ericsson|mot|samsung|sgh|lg|philips|panasonic|alcatel|lenovo|cldc|midp|wap|android|iPod/i.test(navigator.userAgent.toLowerCase())) {
    console.log("mobile");
}

复制代码 代码如下:

本月看到三个功能比较有趣,特此记录一下

那个地点首尽管使用了设备自带的趋向检查测试功能,随着设备的角度分歧,给Logo加上一些滚动作效果应

示例

(function () {              var MOBILE_SITE = 'http://m.xx.com/index.html',                   NO_REDIRECT = 'noredirect';              if (isMobile.any) {                  if ( document.cookie.indexOf(NO_REDIRECT) === -1 ) {                      document.location = MOBILE_SITE;                  }              }          })();

<?php
韦德国际1946国际网址,class Mobi {
function __isMobile() {
$useragent=$_SERVER['HTTP_USER_AGENT'];
if(preg_match('/android|avantgo|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)/|plucker|pocket|psp|symbian|treo|up.(browser|link)|vodafone|wap|windows (ce|phone)|xda|xiino/i',$useragent)||preg_match('/1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw-(n|u)|c55/|capi|ccwa|cdm-|cell|chtm|cldc|cmd-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc-s|devi|dica|dmob|do(c|p)o|ds(12|-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(-|_)|g1 u|g560|gene|gf-5|g-mo|go(.w|od)|gr(ad|un)|haie|hcit|hd-(m|p|t)|hei-|hi(pt|ta)|hp( i|ip)|hs-c|ht(c(-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i简短的运动器材检查评定PHP脚本代码,检查评定移动设备。-(20|go|ma)|i230|iac( |-|/)|ibro|idea|ig01|ikom|im1k|inno|ipaq|iris|ja(t|v)a|jbro|jemu|jigs|kddi|keji|kgt( |/)|klon|kpt |kwc-|kyo(c|k)|le(no|xi)|lg( g|/(k|l|u)|50|54|e-|e/|-[a-w])|libw|lynx|m1-w|m3ga|m50/|ma(te|ui|xo)|mc(01|21|ca)|m-cr|me(di|rc|ri)|mi(o8|oa|ts)|mmef|mo(01|02|bi|de|do|t(-| |o|v)|zz)|mt(50|p1|v )|mwbp|mywa|n10[0-2]|n20[2-3]|n30(0|2)|n50(0|2|5)|n7(0(0|1)|10)|ne((c|m)-|on|tf|wf|wg|wt)|nok(6|i)|nzph|o2im|op(ti|wv)|oran|owg1|p800|pan(a|d|t)|pdxg|pg(13|-([1-8]|c))|phil|pire|pl(ay|uc)|pn-2|po(ck|rt|se)|prox|psio|pt-g|qa-a|qc(07|12|21|32|60|-[2-7]|i-)|qtek|r380|r600|raks|rim9|ro(ve|zo)|s55/|sa(ge|ma|mm|ms|ny|va)|sc(01|h-|oo|p-)|sdk/|se(c(-|0|1)|47|mc|nd|ri)|sgh-|shar|sie(-|m)|sk-0|sl(45|id)|sm(al|ar|b3|it|t5)|so(ft|ny)|sp(01|h-|v-|v )|sy(01|mb)|t2(18|50)|t6(00|10|18)|ta(gt|lk)|tcl-|tdg-|tel(i|m)|tim-|t-mo|to(pl|sh)|ts(70|m-|m3|m5)|tx-9|up(.b|g1|si)|utst|v400|v750|veri|vi(rg|te)|vk(40|5[0-3]|-v)|vm40|voda|vulc|vx(52|53|60|61|70|80|81|83|85|98)|w3c(-| )|webc|whit|wi(g |nc|nw)|wmlb|wonu|x700|xda(-|2|g)|yas-|your|zeto|zte-/i',substr($useragent,0,4))) {
//header('Location: ');
return true;
}
return false;
}
}
?>

拍卖方向的轩然大波

  window.addEventListener('deviceorientation',function(e){
            var alpha = e.aplha;
            var beta = e.beta;
            var gamma = e.gamma;
            console.log('alpha:' alpha ',beta:' beta ',gamma:' gamma);  
        });

借用一张图来讲授下阿尔法,beta,gamma的涉嫌

领会了定义之后,就能够开首应用那个值做点事了。不过此地有1个标题不怕,大家并无法用单壹的值去做总括,并且方向普通还和手提式有线电话机的放置地点有关,并且在Android上陀螺仪的数码不是很平静,需求加一些方式做缓冲。
辛亏有多少个零件已经处理好了上边的那一个难点,并且还独立提供了七个计算出来的值,分别是lon,lat,字面意思是经度和纬度,能够算作平移的离开

上边用三个小例子来展示一下:
演示 源码

var clientWidth = document.documentElement.clientWidth;
        var left = (600 - clientWidth)/2;
        $('div').css('left','-'   left  'px');
// 这里主要是让图片居中,为了效果好一点,选择双倍图然后进行缩放
        var ori = new Orienter();
        ori.onOrient = function(obj){
            var a,b;

            a = obj.lon < 180 ? obj.lon : obj.lon - 360; //计算出来的lon是0~360 转换为180~-180
            b = obj.lat;

            a = a > 0 ? a > left ? left : a : a < '-'   left ? '-'   left : a;
            b = b > 0 ? b > 20 ? 20 : b : b < -20 ? -20 : b;
            // 控制移动范围

            $('.demo').css("-webkit-transform","translate3d("  a  "px," b "px,0)");
        }

        ori.init();

Why use isMobile?

I had a specific requirement for a project when I created this:

- Redirect all iPhones, iPods, Android phones, and seven inch devices to the mobile site.

A completely separate site had been created for mobile devices, so feature detection/graceful degredation/progressive enhancement were out of the question. I had to redirect.

I couldn’t do detection on the back-end, because the entire site was cached and served by Akamai; I had to do the detection client-side.

So I resorted to UA sniffing.

I tried to keep the script small ( currently ~1.3k bytes, minified ) and simple, because it would need to execute in the   <head> , which is generally a bad idea, since JS blocks downloading and rendering of anything else while it parses and executes. In the case of mobile redirection, I don’t mind so much, because I want to start the redirect as soon as possible, before the device has a chance to start downloading and rendering stuff. For non-mobile platforms, the script should execute fast, so the browser can quickly get back to downloading and rendering.

您恐怕感兴趣的篇章:

  • PHP剖断手提式有线电话机是IOS还是Android
  • 因此JavaScript或PHP检测Android设备的代码
  • thinkphp判别访客为手机端或PC端的方法
  • PHP简单推断手机配备的主意
  • PHP代码判定设备是手提式有线电话机大概平板Computer(三种方法)
  • PHP完结基于设备档案的次序自动跳转相应页面包车型地铁格局
  • PHP检查评定移动器具类mobile detection使用实例
  • PHP轻松判定Samsung、苹果平板、Android及PC设备的法门

参考

MDN
JavaScript 陀螺仪检查实验设施方向(引力感应)
orienter

本文由韦德国际1946发布于韦德国际1946国际网址,转载请注明出处:简短的运动器材检查评定PHP脚本代码,检查评定

关键词: js 技术人生 前端学习笔记