JS_点击事件_弹出窗口_自动消失
<!doctype html> <html> <head> <meta charset="utf-8"/> <title>电灯开关案例</title> <script> /** 练习:点击按钮,开灯或关灯 */ var flag = false;//false表示默认状态为关灯 function changeImg(){ console.log("this is show work good!"); showInfo=window.open("3.html",'','width=200,height=100'); } function closeit() { setTimeout("showInfo.close()", 2000) //毫秒 } </script> </head> <body> <input type="button" value="开/关灯" onclick="changeImg()" /> <br/><br/> <body onload="closeit()"> </body> </html>