qq_您_8
2018-03-07 19:11
<!DOCTYPE html>
<html>
<head>
<title> new document </title>
<meta http-equiv="Content-Type" content="text/html; charset=gbk"/>
<script type="text/javascript">
function openWindow(){
var open=confirm("确定打开新网址吗?);
// 新窗口打开时弹出确认框,是否打开
if(open==ture)
{ var url=prompt(确定打开的网址http://www.imooc.com/)
// 通过输入对话框,确定打开的网址,默认为 http://www.imooc.com/
if(url!=null)
{window.open('url' '_blank' 'width=400px,height=500px');} //打开的窗口要求,宽400像素,高500像素,无菜单栏、无工具栏。
else
{alert("打开失败");}
else
{alert("打开失败");}
}
</script>
</head>
<body>
<input type="button" value="新窗口打开网站" onclick="openWindow()" />
</body>
</html>
请问为什么弹出alert窗口之后,就没有弹出输入网址的窗口
刚刚帮同学的代码测试了一下,发现同学的代码有些语法错误呀,
open=true,而不是ture哦。。
格式:prompt("str1","str2"); 还有 window.open();
最后就是alert(); 分号要用英文半角(程序的符号都要用英文半角呐)。
var url=prompt("确定打开的网址?","http://www.imooc.com/");
JavaScript入门篇
741024 学习 · 9681 问题
相似问题