zoukankan      html  css  js  c++  java
  • PC端手机访问跳转手机站点

    第一种:

    var _hmt = _hmt || [];
    (function() {
      var hm = document.createElement("script");
      hm.src = "//hm.baidu.com/hm.js?";
      var s = document.getElementsByTagName("script")[0];
      s.parentNode.insertBefore(hm, s);
    })();
    var mobileAgent = new Array("iphone", "ipod", "ipad", "android", "mobile", "blackberry", "webos", "incognito", "webmate", "bada", "nokia", "lg", "ucweb", "skyfire");
    var browser = navigator.userAgent.toLowerCase();
    var isMobile = false;
    for (var i=0; i<mobileAgent.length; i++){ if (browser.indexOf(mobileAgent[i])!=-1){ isMobile = true;
    location.href = 'http://m.nk91.org/';
    break; } }

    在PC端首页加上

    <script language="javascript" type="text/javascript" src="/js/shouji.js"></script>

    可以把以上的JS保存在shouji.js在PC端首页加上这段JS引进;

    第二种:

    //移动端跳转
    
    var mobileAgent = new Array("iphone", "ipod", "ipad", "android", "mobile", "blackberry", "webos", "incognito", "webmate", "bada", "nokia", "lg", "ucweb", "skyfire");
    var browser = navigator.userAgent.toLowerCase();
    var isMobile = false;
    for (var i=0; i<mobileAgent.length; i++){ if (browser.indexOf(mobileAgent[i])!=-1){ isMobile = true;
    location.href = 'http://m.nk91.org/';
    break; } }
    //移动端跳转end
    
    
    document.writeln("<script src="/t/style/js/tel.js" type="text/javascript"></script>");

    第二种自己没有常识过,不过应该也可以。直接保存到shouji.js或者网站公用的foot.js引进即可;

  • 相关阅读:
    Django之模板
    Web框架的原理
    mysql 索引
    pymysql模块的使用
    MySQl创建用户和授权
    php去除h5标签
    phpcms_完整版
    快速上手Linux 玩转典型应用_慕课网笔记
    php 微擎
    二维码接口
  • 原文地址:https://www.cnblogs.com/kpengfang/p/4818227.html
Copyright © 2011-2022 走看看