<!DOCTYPE html>
<html>
<head>
	<title>设备检测跳转</title>
	<meta charset="utf-8">
	<meta name="viewport" content="width=device-width, initial-scale=1.0">
	<script type="text/javascript">
		// 检测设备类型
		var isMobile = /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent);
		var isAndroid = /Android/i.test(navigator.userAgent);
		var isIOS = /iPhone|iPad|iPod/i.test(navigator.userAgent);
		var isWechat = /MicroMessenger/i.test(navigator.userAgent);
<pre><code>	// 根据设备类型跳转不同页面
	 if (isMobile) {
		 if (isAndroid) {
			 window.location.href = 'https://your-android-url.com';
		 } else if (isIOS) {
			 window.location.href = 'https://your-ios-url.com';
		 } else {
			 window.location.href = 'https://your-mobile-url.com';
		 }
	 } else {
		 if (isWechat) {
			 window.location.href = 'https://your-wechat-url.com';
		 } else {
			 window.location.href = 'https://your-pc-url.com';
		 }
	 }
&lt;/script&gt;
</code></pre>
</head>
<body>
	<h1>正在检测设备类型...</h1>
</body>
</html>
JavaScript 设备检测跳转 - 自动识别移动端、安卓、苹果、微信

原文地址: https://www.cveoy.top/t/topic/mF8W 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录