iamawin21
2017-07-13 17:19
<!DOCTYPE html>
<html>
<head>
<title> new document </title>
<meta http-equiv="Content-Type" content="text/html; charset=gbk"/>
<script type="text/javascript">
function mychar;
var mychar=confirm(“是否打开新的窗口?”);
// 新窗口打开时弹出确认框,是否打开
if (mychar==true)
// 通过输入对话框,确定打开的网址,默认为 http://www.imooc.com/
{window.open("http://www.imooc.com/"_'blank','width=400','height=500','status=no,menobar=no,toolbar=no,scrollbar=yes');}
//打开的窗口要求,宽400像素,高500像素,无菜单栏、无工具栏。
else
{document.write(“真讨厌!”)};
</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=utf-8" />
<script type="text/javascript">
function openWindow(){
var mychar=confirm("是否打开新的窗口?");
// 新窗口打开时弹出确认框,是否打开
if (mychar==true)
// 通过输入对话框,确定打开的网址,默认为 http://www.imooc.com/
{window.open("http://www.imooc.com/",'_blank',
'width=400,height=500,status=no,menobar=no,toolbar=no,scrollbar=yes');
}
//打开的窗口要求,宽400像素,高500像素,无菜单栏、无工具栏。
else
{
document.write("真讨厌!");
}
}
</script>
</head>
<body>
<input type="button" value="新窗口打开网站" onclick="openWindow()" />
</body>
</html>1.function格式不对;2.编程符号必须用英文输入法!!!3.window.open()的参数格式也不对;4.onclick调用的函数名应该与function的函数名一致。再好好看看前面的课程吧
function mychar; 这得格式错了
JavaScript入门篇
741594 学习 · 9869 问题
相似问题