關(guān)閉已打開的窗口。
<!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("你確定要關(guān)閉窗口么?"); if(my?==?true){ myOpenWindow.close(); }else{ alert("我的小乖乖,以后有什么事兒記得你的度娘哈!"); } </script> </head> <body> </body> </html>
我的問題是打開窗口,執(zhí)行完confirm(),點(diǎn)擊確定怎么關(guān)不了打開的窗口呢?
2017-01-06
因?yàn)橄旅鏇]有代碼執(zhí)行關(guān)閉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("你確定要關(guān)閉窗口么?");
if(my ==true){
? ? myOpenWindow.close();
}else{
? ? alert("我的小乖乖,以后有什么事兒記得你的度娘哈!");
}
?} ? ?
</script>
</head>
<body>
<input name="button" type="button" onClick="rec()" value="點(diǎn)擊查看網(wǎng)頁" >
</body>
</html>