手机访问pc地址时直接跳到移动端

function mobile_device_detect(url) {
    var thisOS = navigator.platform;
    var os = new Array("iPhone", "iPod", "iPad", "android", "Nokia", "SymbianOS", "Symbian", "Windows Phone", "Phone", "Linux armv71", "MAUI", "UNTRUSTED/1.0", "Windows CE", "BlackBerry", "IEMobile");
    for (var i = 0; i < os.length; i++) {
        if (thisOS.match(os[i])) {
            window.location = url;
        }

    }
    //因为相当部分的手机系统不知道信息,这里是做临时性特殊辨认
    if (navigator.platform.indexOf(‘iPad‘) != -1) {
        window.location = url;
    }
    //做这一部分是因为Android手机的内核也是Linux
    //但是navigator.platform显示信息不尽相同情况繁多,因此从浏览器下手,即用navigator.appVersion信息做判断
    var check = navigator.appVersion;
    if (check.match(/linux/i)) {
        //X11是UC浏览器的平台 ,如果有其他特殊浏览器也可以附加上条件
        if (check.match(/mobile/i) || check.match(/X11/i)) {
            window.location = url;
        }
    }
    //类in_array函数
    Array.prototype.in_array = function (e) {
        for (i = 0; i < this.length; i++) {
            if (this[i] == e)
                return true;
        }
        return false;
    }
}
mobile_device_detect("http://m.eosmedchem.com");
时间: 2024-08-09 22:22:50

手机访问pc地址时直接跳到移动端的相关文章

手机访问pc版网站自动跳转为手机版页面

function getMCookie(objName) { var arrStr = document.cookie.split("; "); for (var i = 0; i < arrStr.length; i++) { var temp = arrStr[i].split("="); if (temp[0] == objName) { return unescape(temp[1]); } } return ""; } funct

手机访问pc网站,自动跳转到手机网站

<script type='text/javascript'> var browser = { versions: function () { var u = navigator.userAgent, app = navigator.appVersion; return {//移动终端浏览器版本信息 trident: u.indexOf('Trident') > -1, //IE内核 presto: u.indexOf('Presto') > -1, //opera内核 webKi

手机访问PC网站自动跳转到手机网站代码(转)

4G时代,手机网站已经非常普遍了,一般手机网站都有一个二级域名来访问,比如 m.16css.com 如果手机直接访问www.16css.com 就是PC网站,在手机上浏览电脑版网站体验非常不好. 如果能够手机访问PC端电脑网站自动跳转到手机网站就好了: 代码如下: 将以下代码放在首页区 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 3

手机访问PC网站自动跳转到手机版

随着智能手机的流行,4G时代来临,手机用户越来越多,在生活中甚至手机比电脑用的还多,当前开发的网站大都是PC和WAP版并存,但是很少有用户愿意去记住一个网站的两个端的不同域名,所以需要我们做一些设置,在用户访问首页的时候,进行分析跳转,现将网上流行的几种方式汇总如下,希望对大家有用: 第一种方式:推荐,简单易用,亲测可以正常使用,代码如下: <script src="http://siteapp.baidu.com/static/webappservice/uaredirect.js&qu

手机访问PC网站自动跳转到手机网站代码

第一 <SCRIPT LANGUAGE="JavaScript"> function mobile_device_detect(url) { var thisOS=navigator.platform; var os=new Array("iPhone","iPod","iPad","android","Nokia","SymbianOS","S

利用JS实现手机访问PC网址自动跳转到wap网站

方法一:使用百度siteapp中的js进行判断 <script src="http://siteapp.baidu.com/static/webappservice/uaredirect.js" type="text/javascript"></script><script type="text/javascript">uaredirect("需要跳转的手机网址")</script&g

手机访问pc网站自动跳转手机端网站代码

<script>alert(navigator.platform) ; 获取服务端设备!</script> 备注这里的 mobile_device_detect("http://***.***.com");//里面的地址填的就是您的移动端的网站地址呦. <SCRIPT LANGUAGE="JavaScript"> function mobile_device_detect(url) { var thisOS=navigator.p

JS手机访问PC端网站自动跳转到手机端网站

<script type="text/javascript">//移动端url跳转,自定义部分开始    function mobile_device_detect(url) {        var thisOS = navigator.platform;        var os = new Array("iPhone", "iPod", "iPad", "android", "

手机访问pc网站自动跳转手机端网站PHP代码

$agent = $_SERVER['HTTP_USER_AGENT']; if(strpos($agent,"comFront") strpos($agent,"iPhone") strpos($agent,"MIDP-2.0") strpos($agent,"Opera Mini") strpos($agent,"UCWEB") strpos($agent,"Android") st