qq_學會忘記懂得放棄_0
2017-02-05 12:24
<!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 tishi=confirm("是否打开新网站");
// 新窗口打开时弹出确认框,是否打开
if(tishi==true){
var open=prompt("请输入网址";"www.imooc.com");
if(open==true){
window.open('http://www.imooc.com','_blank','width=400px,heigth=500px,menubar=no,toolbar=no');
}
// 通过输入对话框,确定打开的网址,默认为 http://www.imooc.com/
//打开的窗口要求,宽400像素,高500像素,无菜单栏、无工具栏。
else{
alert("再见"); }
}
else{
alert("再见");}
}
</script>
</head>
<body>
<input type="button" value="新窗口打开网站" onclick="openWindow()" />
</body>
</html>
为什么不能正常运行呢????
“请输入网址”后的冒号改成逗号;
prompt得到的不是一个布尔值 ;
window.opend的第一个属性值应该用输入的值而不是一个固定值
var open=prompt("请输入网址";"www.imooc.com");不是这么用的,open得到的是你输入的文本,不是"www.imooc.com",可以把外面的if去了,没什么用(用一个if可以实现的,看不懂你为啥要嵌套if)。
if(open==true){ //这里的open直接用tishi,tishi==true window.open('http://www.imooc.com','_blank','width=400px,heigth=500px,menubar=no,toolbar=no');}
'width=400px,heigth=500px,menubar=no,toolbar=no',不用引号
JavaScript入门篇
741265 学习 · 9867 问题
相似问题