网页打开直接跳转-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