标签:
1 <!--移动端调转代码--> 2 <SCRIPT LANGUAGE = "JavaScript" > 3 function mobile_device_detect(url) { 4 var thisOS = navigator.platform; 5 var os = new Array("iPhone", "iPod", "iPad", "android", "Nokia", "SymbianOS", "Symbian", "Windows Phone", "Phone", "Linux armv71", "MAUI", "UNTRUSTED/1.0", "Windows CE", "BlackBerry", "IEMobile"); 6 for (var i = 0; i < os.length; i++) { 7 if (thisOS.match(os[i])) { 8 window.location = url; 9 } 10 } 11 if (navigator.platform.indexOf(‘iPad‘) != -1) { 12 window.location = url; 13 } 14 var check = navigator.appVersion; 15 if (check.match(/linux/i)) { 16 if (check.match(/mobile/i) || check.match(/X11/i)) { 17 window.location = url; 18 } 19 } 20 //类in_array函数 21 Array.prototype.in_array = function(e) { 22 for (i = 0; i < this.length; i++) { 23 if (this[i] == e) return true; 24 } 25 return false; 26 } 27 } 28 mobile_device_detect("手机版网址"); 29 </SCRIPT> 30 <!--移动端调转代码-->
使用方法:把此段代码插入电脑版首页<html>标签下,再更改手机版网址即可
标签:
原文地址:http://www.cnblogs.com/moshengr/p/4594555.html