<!doctype html>
<html>
<head>
<meta charset="utf-8">
<script type="text/javascript">
function openWindow(){
var confirmUrl=confirm("是否打开新窗口?")
if(confirmUrl==true)
{
var address = prompt("即将打开以下网址","http://www.baidu.com");
if(address != null)
{
window.open(address,'_blank','width=400,height=500,menubar=no,scrollbar=yes')
}
else
{
document.write("您已经放弃操作");
}
}
else
{
alert("很遗憾,bye!");
}
}
</script>
</head>
<body>
<input type="button" value="新窗口打开网站" onclick="openWindow()" />
</body>
</html>任务
1、新窗口打开时弹出确认框,是否打开
提示: 使用 if 判断确认框是否点击了确定,如点击弹出输入对话框,否则没有任何操作。
2、通过输入对话框,确定打开的网址,默认为 http://www.baidu.com/
3、打开的窗口要求,宽400像素,高500像素,无菜单栏、无工具栏。
以上用到的知识点包括:confirm(); prompt(); window.open().