zoukankan      html  css  js  c++  java
  • JavaScript中window.open()打开与window.close()关闭

    close()关闭窗口,语法书写如下,其次使用close()在打开新窗口的同时,关闭该窗口,是看不到被打开窗口的

    1 window.close();//关闭本窗口
    2 <窗口对象>.close();//关闭指定的窗口

     代码展示:

     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')//将新打的窗口对象,存储在变量ceshi中
    12         // // ceshi.wondows.close()   错误写法
    13         ceshi.close()
    14     </script>
    15 </head>
    16 <body>
    17     <input type="button" name="" id="" value="点击打开新窗口" onclick="myopen()" />
    18 </body>
    19 </html>

     使用<窗口对象>.close();//关闭指定的窗口 代码展示:

     1 <!DOCTYPE html>
     2 <html>
     3 <head>
     4     <meta charset="UTF-8">
     5     <title>通过变量关闭窗口</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();//关闭本窗口 暂时不是很懂,感兴趣的可以参考下这个,后期有机会在完善

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

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

    ==修改时间2020/04/08/20:58 window.close();//关闭本窗口

     1 <!DOCTYPE html>
     2 <html>
     3     <head>
     4         <meta charset="utf-8">
     5         <title>JavaScript-关闭窗口(window.close)</title>
     6         <script type="text/javascript">
     7             // window.close();   //关闭本窗口
     8             // <窗口对象>.close();   //关闭指定的窗口
     9             
    10             // window.open('http://www.dhnblog.com/','_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.dhnblog.com/','_blank','top=100,left=100,width=200,height=300,menubar=yes,toolbar=yes,status=no,scrollbars=yes');
    14             // //将新打的窗口对象,存储在变量mywin中
    15             mywin.close();
    16         </script>
    17     </head>
    18     <body>
    19         <p>上面代码在打开新窗口的同时,关闭该窗口,看不到被打开的窗口。</p>
    20     </body>
    21 </html>
  • 相关阅读:
    Tp控制器
    thinkphp总体设计
    视频会议管理系统操作步骤(新)
    视频会议(旧)
    HCIE实验LAB_1(1)
    HCIE实验LAB_1(2)
    HCIE实验LAB_1(3)
    HCIE实验LAB_1(4)
    HCIE实验LAB_1(5)
    HCIE实验LAB_1(6)
  • 原文地址:https://www.cnblogs.com/webaction/p/12494994.html
Copyright © 2011-2022 走看看