Mslow_CX
2014-11-23 12:38
运行不了
其实你代码真正的错误之处是if...else语句写错了。正确的写法为
if(条件判断语句){
//执行代码块
}else{
//执行代码块
}if的大括号后不加分号的,else大括号后面也不用加分号。
另外在代码规范、标准上而言,建议在每一句执行语句写完后把代分号加上,就和楼上说的那样加,但是不要在if...else上加哦~
function openWindow(){
var a;//加分号
var b;//加分号
a=confirm("will you open a window?"); //加分号
if (a==true){
b=prompt("please input the address"); //加分号
if (b==null){
window.open("http://www.imooc.com/","_blank","width=400,height=500,toolbar=no,menubar=no")};
else{
window.open(b,"_blank","width=400,height=500,toolbar=no,menubar=no")};
}
}
}
把分号补全
JavaScript入门篇
741615 学习 · 9869 问题
相似问题