1、html內直接使用跳轉
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>welcome</title>
</head>
<body>
</body>
<script>
/* 手機---pc */
if (/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera| Mini/i.test(navigator.userAgent)) {
top.location = " ";
} else {
top.location = " ";
}
</script>
</html>
2、js中使用代碼(釘釘官網使用方式)
if(/Android|webOS|iPhone|iPod|BlackBerry/i.test(navigator.userAgent)) {
window.location.href = "https://www.baidu.com/";
} else {
window.location.href = "http://news.baidu.com/";
}
其中:移動端打開的話那就跳轉到 "https:www.baidu.com/" ,如果不是就跳轉到"http://new.baidu.com/"