热门关键字:
jquery > jquery教程 > javascript > javascript获取终端的相关信息跳转不同页面

javascript获取终端的相关信息跳转不同页面

1368
作者:管理员
发布时间:2015/5/4 16:35:42
评论数:0
转载请自觉注明原文:http://www.jq-school.com/Show.aspx?id=544
// 获取终端的相关信息
var Terminal = {
	// 辨别移动终端类型
	platform : function() {
		var u = navigator.userAgent, app = navigator.appVersion;
		return {
			// 是否为iPhone或者QQHD浏览器
			iPhone : u.indexOf('iPhone') > -1,
			// 是否iPad
			iPad : u.indexOf('iPad') > -1,
			// 是否微信
			weixin : u.toLowerCase().indexOf("micromessenger") > -1,
			// android终端或者uc浏览器
			android : u.indexOf('Android') > -1 || u.indexOf('Linux') > -1,
			// 是否WinPhone
			wp : u.indexOf('Windows Phone') > -1
		};
	}(),
}
// 根据不同的终端,跳转到不同的地址
if (Terminal.platform.weixin) {
	location.href = '';
} else if (Terminal.platform.wp) {
	location.href = '';
} else if (Terminal.platform.android) {
	location.href = '';
} else if (Terminal.platform.iPhone) {
	location.href = '';
} else if (Terminal.platform.iPad) {
	location.href = '';
}




如果您觉得本文的内容对您的学习有所帮助:支付鼓励



关键字:javascript 移动设备 android ios
友荐云推荐