<!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==true){
var url =prompt("确定打开的网页","https://www.imooc.com");
if (url!=null){
window.open(por,"_blank",'width=400px,height=500px,menubar=no,toolar=no');
}
}
// 通过输入对话框,确定打开的网址,默认为 http://www.imooc.com/
else
{alert("bye-bye");}
else
{alert("bye-bye");}
}
//打开的窗口要求,宽400像素,高500像素,无菜单栏、无工具栏。
</script>
</head>
<body>
<input type="button" value="新窗口打开网站" onclick="openWindow()" />
</body>
</html>
给你看一个简洁的javascript
<script type="text/javascript"> function openWindow(){ var w = confirm("No or Yes ?"); if(w){ var url =prompt( "输入要打开的网址", "https://www.imooc.com"); if (url != null){ window.open( url, "_blank", "width=400px,height=500px,menubar=no,toolar=no"); } } } </script>
<!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==true){
var url =prompt("确定打开的网页","https://www.imooc.com");
if (url!=null){
window.open(url,"_blank",'width=400px,height=500px,menubar=no,toolar=no');
}
//else必须写在里面与里面的if相对应
// 通过输入对话框,确定打开的网址,默认为 http://www.imooc.com/
else
{alert("bye-bye"); }
}
else
{alert("bye-bye");}
}
</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 open=confirm("是否打开?");
//新窗口打开时弹出确认框,是否打开
if(open==true){
var url =prompt("确定打开的网页","https://www.imooc.com");
if (url!=null){
window.open(por,"_blank",'width=400px,height=500px,menubar=no,toolar=no');
}
//else必须写在里面与里面的if相对应
// 通过输入对话框,确定打开的网址,默认为 http://www.imooc.com/
else
{alert("bye-bye"); }
}
else
{alert("bye-bye");}
}
</script>
</head>
<body>
<input type="button" value="新窗口打开网站" onclick="openWindow()" />
</body>
</html>