關閉已打開的窗口。
<!DOCTYPE?html> <html> <head> <meta?charset="UTF-8"> <title>window.open(打開新窗口?)</title> <script?type?=?"text/JavaScript"> var?myOpenWindow?=?window.open('http://www.baidu.com'); var?my?=?confirm("你確定要關閉窗口么?"); if(my?==?true){ myOpenWindow.close(); }else{ alert("我的小乖乖,以后有什么事兒記得你的度娘哈!"); } </script> </head> <body> </body> </html>
我的問題是打開窗口,執行完confirm(),點擊確定怎么關不了打開的窗口呢?
2017-01-06
因為下面沒有代碼執行關閉confirm
2017-03-14
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>window.open(打開新窗口 )</title>
<script type = "text/JavaScript">
function rec(){
var myOpenWindow = window.open('http://www.baidu.com');
var my = confirm("你確定要關閉窗口么?");
if(my ==true){
? ? myOpenWindow.close();
}else{
? ? alert("我的小乖乖,以后有什么事兒記得你的度娘哈!");
}
?} ? ?
</script>
</head>
<body>
<input name="button" type="button" onClick="rec()" value="點擊查看網頁" >
</body>
</html>