慕粉4370907
2016-11-29 10:52
上面的代码试了没有?
<!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 meg=confirm("确认打开新窗口吗");
if(meg==true){
// 通过输入对话框,确定打开的网址,默认为 http://www.imooc.com/
//打开的窗口要求,宽400像素,高500像素,无菜单栏、无工具栏。
window.open('http://www.imooc.com',
'width=400px,height=500px,menubar=no,toolbar=no');
}
}
</script>
</head>
<body>
<input type="button" value="新窗口打开网站" onclick="openWindow()" />
</body>
</html>
这是我写的代码 这个很简单的 你写的有点复杂了
<!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 mysrt = confirm("是否打开网页");
if (mysrt == true) {
// 通过输入对话框,确定打开的网址,默认为 http://www.imooc.com/
var my = prompt("请输入网址", "http://www.imooc.com/");
if (my != null) {
//打开的窗口要求,宽400像素,高500像素,无菜单栏、无工具栏。
window.open(my, 'http://www.imooc.com', '_blank', 'width=400px,height=500px,menubar=no,toolbar=no')
}
else{
alert("再见");
}
}
else {
alert("再见!");
}
}
</script>
</head>
<body>
<input type="button" value="新窗口打开网站" onclick="openWindow()" />
</body>
</html>
JavaScript入门篇
741114 学习 · 9865 问题
相似问题
回答 4
回答 5