function openWindow(){ var a=confirm("确定打开吗"); if(a==true){ // document.write("banruili"); windows.open(' http://www.imooc.com/','_blank','width=400,height=500'); }else{ // document.write("banrui"); windows.close(); } }
4 回答
小新在编程
TA贡献15条经验 获得超10个赞
<!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 a=confirm("确定打开吗");
//confirm()会弹出一个对话框,点击确定会返回true, 取消返回false,直接可以把a放在if()里,不用再做判断
if(a){
// document.write("banruili");
window.open('http://www.imooc.com/','_blank','width=400,height=500');
}else{
// document.write("banrui");
windows.close();
}
}
</script>
</head>
<body>
<input type="button" value="新窗口打开网站" onclick="openWindow()" />
</body>
</html>编程的时候注意英文中文标点符号,中文标点符号会出错的;
第二window.oepn,不是windows.open,没有这个;
第三,编程在sublime3或者Dreamweaver下编程,这样错误要好找一些
韩显成
TA贡献4条经验 获得超5个赞
windows.open(' http://www.imooc.com/','_blank','width=400,height=500');//http后面的“:”也是中文的
添加回答
举报
0/150
提交
取消
