开、关窗口

<body>
    <a href="">点我打开一个新的页面</a>
    <a href="">点我关闭本页面</a>

    
</body>

    var a1 = document.getElementsByTagName('a')[0]
    var a2 = document.getElementsByTagName('a')[1]
    a1.onclick = function(){
        
        window.open("http://www.baidu.com","_blank",'width=100px,height=100px')
    }

    a2.onclick = function(){
        window.close();
    }

posted @ 2021-03-20 18:00  yuanliy  阅读(34)  评论(0编辑  收藏  举报