• 移动端和PC端区分


    1、移动端包括:浏览器、ios/android、qq端、微信端

      九度数据官网源码。修改,要跳转的链接即可。

     function browserRedirect() {
            var sUserAgent = navigator.userAgent.toLowerCase();
            var bIsIpad = sUserAgent.match(/ipad/i) == "ipad";
            var bIsIphoneOs = sUserAgent.match(/iphone os/i) == "iphone os";
            var bIsMidp = sUserAgent.match(/midp/i) == "midp";
            var bIsUc7 = sUserAgent.match(/rv:1.2.3.4/i) == "rv:1.2.3.4";
            var bIsUc = sUserAgent.match(/ucweb/i) == "ucweb";
            var bIsAndroid = sUserAgent.match(/android/i) == "android";
            var bIsCE = sUserAgent.match(/windows ce/i) == "windows ce";
            var bIsWM = sUserAgent.match(/windows mobile/i) == "windows mobile";
            if ((bIsIpad || bIsIphoneOs || bIsMidp || bIsUc7 || bIsUc || bIsAndroid || bIsCE || bIsWM) ){
                window.location.href='http://m.baidu.com/';
            }
        }

      2、腾讯官网源码

    if(/AppleWebKit.*Mobile/i.test(navigator.userAgent) || (/MIDP|SymbianOS|NOKIA|SAMSUNG|LG|NEC|TCL|Alcatel|BIRD|DBTEL|Dopod|PHILIPS|HAIER|LENOVO|MOT-|Nokia|SonyEricsson|SIE-|Amoi|ZTE/.test(navigator.userAgent))){  
          if(window.location.href.indexOf("?mobile")<0){
            try{
                if(/Android|Windows Phone|webOS|iPhone|iPod|BlackBerry/i.test(navigator.userAgent)){
                    window.location.href="http://xw.qq.com/index.htm";
                }else if(/iPad/i.test(navigator.userAgent)){
                  //window.location.href="http://www.qq.com/pad/"
                }else{
                    window.location.href="http://xw.qq.com/simple/s/index/"
                }
            }catch(e){}
        }
        }

     3、360官网源码

    var is_mobi =navigator.userAgent.toLowerCase().match(/(ipod|iphone|android|coolpad|mmp|smartphone|midp|wap|xoom|symbian|j2me|blackberry|wince)/i) != null;
                if(is_mobi){
                    window.location.href = "http://m.360.com";
                }

     4、网易官网源码

    if(/AppleWebKit.*Mobile/i.test(navigator.userAgent) || (/MIDP|SymbianOS|NOKIA|SAMSUNG|LG|NEC|TCL|Alcatel|BIRD|DBTEL|Dopod|PHILIPS|HAIER|LENOVO|MOT-|Nokia|SonyEricsson|SIE-|Amoi|ZTE/.test(navigator.userAgent))) {
            try {
                if(/Android|Windows Phone|webOS|iPhone|iPod|BlackBerry/i.test(navigator.userAgent)) {
                    window.location.href = "http://3g.163.com";
                } else if(/iPad/i.test(navigator.userAgent)) {
                    window.location.href = "http://www.163.com/ipad/";
                }
            } catch(e) {}
        }   
  • 相关阅读:
    WPF中实现Button.Content变化的简易动画
    WPF中ListBox的项ListBoxItem被选中的时候Background变化
    GD库处理图像
    PHP上传文件示例
    会话控制:Cookie和session
    PHP表单与验证
    PHP日期与时间
    PHP正则表达式
    PHP字符串处理
    目录与文件操作
  • 原文地址:https://www.cnblogs.com/zhaoyihao/p/7198735.html
Copyright © 2020-2023  润新知