网页自动跳转检测 - 移动端、安卓、苹果、微信识别
<!DOCTYPE html>
<html>
<head>
<meta charset='UTF-8'>
<title>跳转检测</title>
<script type='text/javascript'>
(function(){
var ua = navigator.userAgent.toLowerCase();
var isMobile = /mobile/i.test(ua);
var isAndroid = /android/i.test(ua);
var isIOS = /iphone|ipad|ipod/i.test(ua);
var isWechat = /micromessenger/i.test(ua);
<pre><code> if(isMobile){
if(isAndroid){
window.location.href = 'android.html';
}else if(isIOS){
window.location.href = 'ios.html';
}else{
window.location.href = 'mobile.html';
}
}else{
if(isWechat){
window.location.href = 'wechat.html';
}else{
window.location.href = 'pc.html';
}
}
})();
</script>
</code></pre>
</head>
<body>
<p>正在跳转中,请稍候...</p>
</body>
</html>
原文地址: https://www.cveoy.top/t/topic/mF8V 著作权归作者所有。请勿转载和采集!