请问哪里出错了
来源:1-14 编程练习
theeyang
2018-10-31 12:27:44
<!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title>打开/关闭页面</title> </head> <body> <input type="button" value="关闭本页面" id="close"> <input type="button" value="打开慕课网" id="open"> <script type="text/javascript"> var close=document.getElementById("close"); var open=document.getElementById("open"); close.onclick=function(){ window.close(); } open.onclick=function(){ window.open("http://www.imooc.com"); } </script> </body> </html>
1回答
close和open不能作为变量名使用哦 , 因为它们是关键字 , 将这里换个其他名字就可以了,如下图所示:
祝学习愉快!
相似问题