qq_我叫酸奶_0
2017-09-07 20:34
function openWindow(){
var mychar=confirm("是否要打开新网址?");
if(mychar==true){
var url=prompt("确定打开的网址","http://www.imooc.com/");
if (url!=null){
window.open(url,'_blank','width=400,height=500,menubar=no,toolbar=no');
}
}
else
{alert("再见");}
}
你的分号和冒号都是中文符的
<!DOCTYPE html>
<html>
<head>
<title> new document </title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<script type="text/javascript">
function openWindow(){
var a = confirm("是否打开?");// 新窗口打开时弹出确认框,是否打开
if(a==true){
window.open("http://www.imooc.com/","_blank","width=400px,hight=500px,menubar=no,toolbar=no");
}// 通过输入对话框,确定打开的网址,默认为 http://www.imooc.com/
}//打开的窗口要求,宽400像素,高500像素,无菜单栏、无工具栏。
</script>
</head>
<body>
<input type="button" value="新窗口打开网站" onclick="openWindow()" />
</body>
</html>
不用prompt,直接window.open就行了
JavaScript入门篇
738244 学习 · 9560 问题
相似问题