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引进即可;

posted @ 2015-09-18 09:12  kpengfang  阅读(652)  评论(0编辑  收藏  举报