日韩黑丝制服一区视频播放|日韩欧美人妻丝袜视频在线观看|九九影院一级蜜桃|亚洲中文在线导航|青草草视频在线观看|婷婷五月色伊人网站|日本一区二区在线|国产AV一二三四区毛片|正在播放久草视频|亚洲色图精品一区

分享

JavaScript中window.open()打開與window.close()關(guān)閉

 小世界的野孩子 2021-11-14

close()關(guān)閉窗口,語法書寫如下,其次使用close()在打開新窗口的同時(shí),關(guān)閉該窗口,是看不到被打開窗口的

1 window.close();//關(guān)閉本窗口
2 <窗口對(duì)象>.close();//關(guān)閉指定的窗口

 代碼展示:

 1 <!DOCTYPE html>
 2 <html>
 3 <head>
 4     <meta charset="UTF-8">
 5     <title>JavaScript中window.open()與window.close()</title>
 6     <script type="text/javascript">
 7         function myopen(){
 8             window.open('https://www.baidu.com/','_blank','width=300,height=200,left=0,meunbar=no,toolbar=no,scrollbar=yes,status=no');
 9         }
10         
11         var ceshi=window.open('https://www.cnblogs.com/dhnblog/p/12494648.html')//將新打的窗口對(duì)象,存儲(chǔ)在變量ceshi中
12         // // ceshi.wondows.close()   錯(cuò)誤寫法
13         ceshi.close()
14     </script>
15 </head>
16 <body>
17     <input type="button" name="" id="" value="點(diǎn)擊打開新窗口" onclick="myopen()" />
18 </body>
19 </html>

 使用<窗口對(duì)象>.close();//關(guān)閉指定的窗口 代碼展示:

 1 <!DOCTYPE html>
 2 <html>
 3 <head>
 4     <meta charset="UTF-8">
 5     <title>通過變量關(guān)閉窗口</title>
 6     <script type="text/javascript">
 7         function myopen(){
 8             var ceshi=window.open('https://www.baidu.com/','_blank','width=300,height=200,left=0,meunbar=no,toolbar=no,scrollbar=yes,status=no');
 9             ceshi.close()
10         }
11     </script>
12 </head>
13 <body>
14     <input type="button" name="" id="" value="我不信你可以打開" onclick="myopen()" />
15 </body>
16 </html>

 至于window.close();//關(guān)閉本窗口 暫時(shí)不是很懂,感興趣的可以參考下這個(gè),后期有機(jī)會(huì)在完善

  1. Javascript:window.close()不起作用?

  2. window.close()的用法 
  3. window方法:close()

==修改時(shí)間2020/04/08/20:58 window.close();//關(guān)閉本窗口

 1 <!DOCTYPE html>
 2 <html>
 3     <head>
 4         <meta charset="utf-8">
 5         <title>JavaScript-關(guān)閉窗口(window.close)</title>
 6         <script type="text/javascript">
 7             // window.close();   //關(guān)閉本窗口
 8             // <窗口對(duì)象>.close();   //關(guān)閉指定的窗口
 9             
10             // window.open('http://www./','_blank','top=100,left=100,width=200,height=300,menubar=yes,toolbar=yes,status=no,scrollbars=yes');
11             //window.close();
12                 
13             var mywin=window.open('http://www./','_blank','top=100,left=100,width=200,height=300,menubar=yes,toolbar=yes,status=no,scrollbars=yes');
14             // //將新打的窗口對(duì)象,存儲(chǔ)在變量mywin中
15             mywin.close();
16         </script>
17     </head>
18     <body>
19         <p>上面代碼在打開新窗口的同時(shí),關(guān)閉該窗口,看不到被打開的窗口。</p>
20     </body>
21 </html>

    本站是提供個(gè)人知識(shí)管理的網(wǎng)絡(luò)存儲(chǔ)空間,所有內(nèi)容均由用戶發(fā)布,不代表本站觀點(diǎn)。請(qǐng)注意甄別內(nèi)容中的聯(lián)系方式、誘導(dǎo)購(gòu)買等信息,謹(jǐn)防詐騙。如發(fā)現(xiàn)有害或侵權(quán)內(nèi)容,請(qǐng)點(diǎn)擊一鍵舉報(bào)。
    轉(zhuǎn)藏 分享 獻(xiàn)花(0

    0條評(píng)論

    發(fā)表

    請(qǐng)遵守用戶 評(píng)論公約

    類似文章 更多