通过navigator.userAgent
识别浏览器设备、从而使用js实现跳转不同设备的目标
<!DOCTYPE html>
<html lang="zh_CN">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<body>
<script type="text/javascript">
var ua = navigator.userAgent.toLowerCase();
if (/mobile|android|iphone|ipad|phone/i.test(ua)) {
window.location.href = "https://m.baidu.com"; //移动端目标
} else {
window.location.href = "https://www.baidu.com"; //PC端目标
}
</script>
</body>
</html>