页面跳转打开和关闭

window.open()打开新页面并跳转
window.location.href=""在本页面跳转

<html>

<head>
    <script language="javascript">
        var newWindow = window.open(document.URL);
        setTimeout('newWindow.close()', 1000);
        setTimeout('window.close()', 2000)
    </script>
</head>

<body>
</body>

</html>
<!DOCTYPE html>
<html>

<head>
    <!-- 方案一 -->
    <meta http-equiv="refresh" content="2;url=https://www.baidu.com" />
</head>

<body>
    <!-- 方案二 -->
    <a href="https://www.baidu.com/">go</a>
    <script language="javascript" type="text/javascript">
        // 方案三
        // 打开新窗口并跳转
        window.open('https://www.baidu.com/', 'newwindow')
        // 方案四        
        // 以下方式直接跳转
        window.location.href = 'https://www.baidu.com/';
        // 方案五
        // 五秒以后再跳转
        setTimeout("javascript:location.href='https://www.baidu.com'", 5000);
    </script>
    </bod>

</html>

window.open() 返回一个window 对象

发布了50 篇原创文章 · 获赞 11 · 访问量 1万+

猜你喜欢

转载自blog.csdn.net/qq_35689096/article/details/104064741