網頁打開直接跳轉-2種方法


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/"


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM