• js判断是否手机端,相对域名跳转到对应的m.手机站


    js判断是否手机端,相对域名跳转到对应的m.手机站

    <script type="text/javascript">(function(Switch) {
        var switch_pc = window.location.hash;
        var curURL = document.location.href; //当前URL
        var isMobile = curURL.indexOf("http://m."); //判断当前URL是否是手机站
        var isPc = curURL.indexOf("http://www."); //判断当前URL是否包含"http://www."
        if (isMobile < 0) { //不是手机站
            if (isPc < 0) { //不包含"http://www."
            var thisURL = curURL.replace(/^http:///, "http://m.");
        } else { // 包含"http://www."
            var thisURL = curURL.replace(/^http://www./, "http://m.");
        }
      }
      if (switch_pc != "#pc") {
        if (/iphone|ipod|ipad|ipad|Android|nokia|blackberry|webos|webos|webmate|bada|lg|ucweb|skyfire|sony|ericsson|mot|samsung|sgh|lg|philips|panasonic|alcatel|lenovo|cldc|midp|wap|mobile/i.test(navigator.userAgent.toLowerCase())) {
          Switch.location.href = thisURL;
        }
        document.write('<meta name="mobile-agent" content="format=html5;url=' + thisURL + '" />');
      }
    })(window);
    </script>
    转载请注明出处: 欢迎留言或qq(1090413588)交流
  • 相关阅读:
    POJ-1465 Multiple
    POJ-2585 Window Pains
    POJ-1094 Sorting It All Out
    Linux基础学习笔记1
    建议3---理解Python与C语言的不同之处
    堆排序的Python实现
    迭代器和生成器详解
    建议2---编写pythonic代码
    python中Switch/Case实现
    建议1---理解Pythonic的概念
  • 原文地址:https://www.cnblogs.com/linyusong/p/6420063.html
Copyright © 2020-2023  润新知