3秒后关闭弹出窗口

use*_*377 8 html javascript html5

我需要在3秒后关闭以下弹出窗口.我该怎么做.

<map id="ImgMap0" name="ImgMap0">
                  <area alt="" coords="127, 22, 20" alt="" title="click here" href="includes/popup1.htm" onclick="javascript:void window.open

('includes/popup1.htm','1366002941508','width=500,height=200,left=375,top=330');return false;" shape="circle" />
</map></p>
Run Code Online (Sandbox Code Playgroud)

Joh*_*ner 15

使用setTimeout,例如:

var win = window.open("http://www.google.com", '1366002941508','width=500,height=200,left=375,top=330');

setTimeout(function () { win.close();}, 3000);
Run Code Online (Sandbox Code Playgroud)

示例小提琴:http://jsfiddle.net/N5rve/


see*_*ker 10

<script type="text/javascript">
 function closeWindow() {
    setTimeout(function() {
    window.close();
    }, 3000);
    }

    window.onload = closeWindow();
    </script>
Run Code Online (Sandbox Code Playgroud)

应该这样做.