html 跳转或打开新网页

html 跳转或打开新网页

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Title</title>

</head>
<body>
<button onclick="location_web()">跳转网页</button>
<button onclick="open_web()">打开新网页</button>
<script>
    function location_web() {
     
     
        window.location = "https://www.baidu.com";
    }
    function open_web() {
     
     
        window.open("https://www.baidu.com");
    }
</script>
</body>
</html>

猜你喜欢

转载自blog.csdn.net/weixin_44493841/article/details/112563893
今日推荐