一直都不对 肯定是某些方面出什么问题了 希望老师可以指出 感觉自己的实际编程能力很差,该怎么提升呢
<!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 choose=confirm("要打开网页吗?");
if(choose==true){//是 true 而不是 ture
var site=prompt("请输入打开的网址",'http://www.imooc.com');
if(site!=null){
window.open(site,'width=400,height=500');//参数的第一个 不要加引号,你用的是一个定义好的参数而不是字符串
}
}
else{
document.write("goodbye");
}
/*
多了一个else
else{
document.write("goodbye");
}*/
// openWindow();加上这个就无限循环了
}
// 新窗口打开时弹出确认框,是否打开
// 通过输入对话框,确定打开的网址,默认为 http://www.imooc.com/
//打开的窗口要求,宽400像素,高500像素,无菜单栏、无工具栏。
</script>
</head>
<body>
<input type="button" value="新窗口打开网站" onclick="openWindow()" />
</body>
</html>基本功不够,多写些代码练练手吧····建议你使用调试工具多调试吧···#我用的是火狐 firebug#···
<!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 choose=confirm("要打开网页吗?");
if(choose==true){
var site=prompt("请输入打开的网址",'http://www.imooc.com');
if(site!=null){
window.open(site,'width=400,height=500');
} else {
document.write("goodbye");
}
} else {
document.write("goodbye");
}
}
</script>
</head>
<body>
<input type="button" value="新窗口打开网站" onclick="openWindow()" />
</body>
</html>你自己对照一下吧,我就不做过多解释了