<!DOCTYPE HTML> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>close()</title> <script type="text/javascript"> function myWin(){ var choice=confirm("你想要打开新窗口吗") if(choice==true) {window.open("http://www.imooc.com");} else { window.close("http://www.imooc.com"); alert("已关闭");} } </script> </head> <body> <form> <input name="button" type="button" onClick="myWin()" value="打开新窗口"> </form> </body> </html>
var choice=confirm("你想要打开新窗口吗")后面缺少;
编的少这些小错误就是多哈,多谢