zoukankan      html  css  js  c++  java
  • 手机访问网站如何自动跳转到手机版本自动转到手机网站

    第一种:

    利用百度Site App代码判断手机访问:

    <script src="http://siteapp.baidu.com/static/webappservice/uaredirect.js" type="text/javascript"></script><script type="text/javascript">uaredirect("http://blog.sina.com.cn/sdask");</script>​
    转自:http://www.cn7080.com/news/116.html
     
    第二种:
    function auto_version() {
        var browser = {
            versions: function () {
                var u = navigator.userAgent, app = navigator.appVersion;
                return {//移动终端浏览器版本信息
                    trident: u.indexOf('Trident') > -1, //IE内核
                    presto: u.indexOf('Presto') > -1, //opera内核
                    webKit: u.indexOf('AppleWebKit') > -1, //谷歌内核
                    gecko: u.indexOf('Gecko') > -1 && u.indexOf('KHTML') == -1, //火狐内核
                    mobile: !!u.match(/AppleWebKit.*Mobile.*/) || !!u.match(/AppleWebKit/), //是否为移动终端
                    ios: !!u.match(/i[^;]+;( U;)? CPU.+Mac OS X/), //ios终端
                    android: u.indexOf('Android') > -1 || u.indexOf('Linux') > -1, //android终端或者uc浏览器
                    iPhone: u.indexOf('iPhone') > -1 || (u.indexOf('Mac') > -1 && u.indexOf('Macintosh') < 0), //是否为iPhone或者QQHD浏览器
                    iPad: u.indexOf('iPad') > -1, //是否iPad
                    webApp: u.indexOf('Safari') == -1 //是否web应该程序,没有头部与底部
                };
            }(),
            language: (navigator.browserLanguage || navigator.language).toLowerCase()
        }
        var to_url = '/m';
        if (!browser.versions.iPad) {
            if (browser.versions.android || browser.versions.iPhone) {
                document.location = to_url;
            }
        }
        if (browser.versions.mobile || browser.versions.ios || browser.versions.android || browser.versions.iPhone || browser.versions.iPad) {
            if (screen.width < 800 || screen.height < 600) {
                document.location = to_url;
            }
        } else {
            if (screen.width <= 320 || screen.height <= 480) {
                document.location = to_url;
            }
        }
    
    }
    auto_version();
    

      

    function auto_version() {    var browser = {        versions: function () {            var u = navigator.userAgent, app = navigator.appVersion;            return {//移动终端浏览器版本信息                trident: u.indexOf('Trident') > -1, //IE内核                presto: u.indexOf('Presto') > -1, //opera内核                webKit: u.indexOf('AppleWebKit') > -1, //谷歌内核                gecko: u.indexOf('Gecko') > -1 && u.indexOf('KHTML') == -1, //火狐内核                mobile: !!u.match(/AppleWebKit.*Mobile.*/) || !!u.match(/AppleWebKit/), //是否为移动终端                ios: !!u.match(/i[^;]+;( U;)? CPU.+Mac OS X/), //ios终端                android: u.indexOf('Android') > -1 || u.indexOf('Linux') > -1, //android终端或者uc浏览器                iPhone: u.indexOf('iPhone') > -1 || (u.indexOf('Mac') > -1 && u.indexOf('Macintosh') < 0), //是否为iPhone或者QQHD浏览器                iPad: u.indexOf('iPad') > -1, //是否iPad                webApp: u.indexOf('Safari') == -1 //是否web应该程序,没有头部与底部            };        }(),        language: (navigator.browserLanguage || navigator.language).toLowerCase()    }    var to_url = 'http://m.91eat.com.cn';    if (!browser.versions.iPad) {        if (browser.versions.android || browser.versions.iPhone) {            document.location = to_url;        }    }    if (browser.versions.mobile || browser.versions.ios || browser.versions.android || browser.versions.iPhone || browser.versions.iPad) {        if (screen.width < 800 || screen.height < 600) {            document.location = to_url;        }    } else {        if (screen.width <= 320 || screen.height <= 480) {            document.location = to_url;        }    }
    }auto_version();

  • 相关阅读:
    报表容器元素的典型用途:保持位置关系+表角斜线
    如何在Wyn仪表板中实现文件下载
    报表表格中的迷你图
    怎么实现固定行数的表格类报表
    如何把自己设计好的仪表板分享给别人?
    报表中的【子弹图】实现方法
    来自不同数据集的图表如何设置联动
    仪表板图表条件格式化设置
    报表中的数据格式设置方法汇总
    仪表板数据表根据用户需求可以自由选择查看的数据列
  • 原文地址:https://www.cnblogs.com/ljl0513/p/4964070.html
Copyright © 2011-2022 走看看