http://www.imooc.com/code/www.imooc.com
代码就是练习的啊。。哪里有问题呢?
<!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 flag=confirm("是否打开网页");
// 通过输入对话框,确定打开的网址,默认为 http://www.imooc.com/
if(flag==true){
var str = prompt("请输入要打开的网页","http://www.imooc.com/");
//打开的窗口要求,宽400像素,高500像素,无菜单栏、无工具栏。
window.open(str,'_blank','width=400px,height=500px,toolbar=no,menubar=no');
}
}
</script>
</head>
<body>
<input type="button" value="新窗口打开网站" onclick="openWindow()" />
</body>
</html>网址有前缀http://
要遵守http协议吧
<!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 str;
str=confirm("是否打开新的网站");
// 新窗口打开时弹出确认框,是否打开
if(str==true){
var str1;
str1=prompt("请输入您要打开的网址","www.imooc.com");
}
// 通过输入对话框,确定打开的网址,默认为 http://www.imooc.com/
if(str==true){
window.open(str1,'_blank','width=400,height=500,menubar=no,toolbar=no');
}
//打开的窗口要求,宽400像素,高500像素,无菜单栏、无工具栏。
}
</script>
</head>
<body>
<input type="button" value="新窗口打开网站" onclick="openWindow()" />
</body>
</html>