JavaScript入门(五) - 关闭窗口(window.close)


<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>关闭窗口title>
    <script type="text/javascript">
        /*
         close()关闭窗口

         用法:
         window.close();   //关闭本窗口

         <窗口对象>.close();   //关闭指定的窗口
         */
        var mywin;
        function windowOpen(){
            mywin = window.open("http://blog.csdn.net/u011712163",'_blank','height=600,width=400,top=100,left=0');
        }

        function windowClose(){
            mywin.close();
        }
    script>
head>
<body>
    <input name="button1" type="button" οnclick="windowOpen()" value="打开新窗口" />
    <input name="button2" type="button" οnclick="windowClose()" value="关闭窗口" />
body>
html>

你可能感兴趣的:(JavaScript)