如何让网站自动识别手机端与PC端

在你需要自动跳转的页面加入以下代码


<script type="text/javascript">
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;
		//alert(mobileAgent[i]);
		location.href = 'http://www.baidu.com';
		break;
	}
}
</script>

转自:http://www.ssffx.com/wangzhanjianshe/313.html

你可能感兴趣的:(如何让网站自动识别手机端与PC端)