手时机见pc网站自动跳转手机端网站代码

4G来临,移动网站已经一发不行收拾,pc端和移动端官网并存。如何让别人会见你的pc端的官网直接跳转到移动端的网站呢?列位看官,小二上代码!来了!

 <SCRIPT LANGUAGE="JavaScript">

 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)

 {

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:https://www.heiqu.com/wsdpwp.html