dd小雷子
2016-06-22 00:50
如果不加prompt,下面这样写错在哪里?求指点。
<script type="text/javascript">
function openWindow(){
var mychar=confirm("确定在新窗口打开网站?");
if(mychar==true){
window.open('http://www.baidu.com',"_blank",'width=500px height=400px');
}
else{
alert("再见");
}
</script>
<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>函数调用</title>
<script type="text/javascript">
function openWindow(){
var mychar=confirm("确定在新窗口打开网站?");
if(mychar==true){
window.open('http://www.baidu.com',"_blank",'width=500px height=400px');
}
else{
alert("再见");
}
}
</script>
</head>
<body>
<form>
<input type="button" value="点击我" onclick="openWindow()" />
</form>
</body>
</html>3个错误。1:var mychar=confirm("确定在新窗口打开网站?");【这里的分号你用的是中文的符号,改为英文的】
2:alert("再见");【这里的分号你用的是中文的符号,改为英文的】
3:function openWindow(){} 【这里的花括号(})是成对的,你在后面就没了】
改完后,运行就没问题了。
我也是新手一枚,不过你_blank那里应该用''而不是""
另外少了个 }
JavaScript入门篇
741594 学习 · 9869 问题
相似问题