<!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 ht=confirm("是否打开网页?"); if(ht==ture){ var wt=prompt("默认打开网页","http://www.imooc.com"); window.open("http://www.imooc.com","_blank", "width=400,height=500,menubar=no,toolbar=no") } } </script> </head> <body> <input type="button" value="新窗口打开网站" onclick="openWindow()" /> </body></html>
10 回答
ziom
TA贡献948条经验 获得超1109个赞
<!DOCTYPE html> <html> <head> <title> new document </title> <meta http-equiv="Content-Type" content="text/html; charset=gbk"/> <script type="text/javascript"> function openWindow(){ <!-- openwindow 改为 openWindow --> var ht=confirm("是否打开网页?"); if(ht==true){ <!-- ture 改为 true --> var wt=prompt("默认打开网页","http://www.imooc.com"); window.open("http://www.imooc.com","_blank", "width=400,height=500,menubar=no,toolbar=no") } } </script> </head> <body> <input type="button" value="新窗口打开网站" onclick="openWindow()" /> </body> </html>
snowmanJS
TA贡献89条经验 获得超53个赞
JavaScript对变量和函数名是区分大小写的,你定义函数是 openwindow(),所以你调用函数时的函数名应该和你定义时的一致,所以应该把onclick="openWindow()"改为onclick="openwindow()"
nickylau82
TA贡献128条经验 获得超67个赞
```javascript
var openWindow = function(){
var ht = confirm("是否打开网页?");
if(ht){
var wt = prompt("默认打开网页","http://www.imooc.com");
window.open(wt,"_blank","width=400,height=500,menubar=no,toolbar=no");
}
};
```
刚毅87
TA贡献345条经验 获得超309个赞
<input type="button" value="新窗口打开网站" onclick="openWindow()" /> 中onclick="openWindow()" 改为onclick="openwindow()"
添加回答
举报
0/150
提交
取消