糖糖很涩
2015-06-03 13:27
<!doctype html>
<html>
<head>
<meta http-equiv="Content-Type"content="text/html;charset=gbk">
<title>new document</title>
<script type="text/javascript">
function openWindow()
{
var open=confirm("确认新建窗口打开网站吗?");
if(open==true)
//新窗口打开时弹出对话框,是否打开
{
var url=prompt("通过输入对话框,确定打开的网址","http://baidu.com");
if(url!=null)
//通过输入对话框,确定打开的网址,默认为http://baidu.com、
{
window.open(url,"_blank",'width=400px,height=500px,menubar=no,toolbar=no');
}
//打开的窗口要求
else{alert("再见!");
}
else
{
alert("再见!");
}
}
</head>
<body>
<input type="button"value="新窗口打开网站"onClick="openWindow()"/>
</body>
</html>
JS里的大括号有问题,调用onclick拼写错误,没有大写。
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html;charset=utf-8">
<title>new document</title>
</head>
<body>
<input type="button" name="submit" value="新窗口打开" onclick="openWindow()" />
</body>
<script type="application/javascript">
function openWindow() {
/*alert("begin");*/
if (confirm("确认新建窗口打开网站吗?")) { //新窗口打开时弹出对话框,是否打开
var url = prompt("通过输入对话框,确定打开的网址", "http://www.baidu.com");
if (url != null && url != "") { //通过输入对话框,确定打开的网址,默认为http://www.baidu.com
window.open(url, "_blank", 'width=400px,height=500px,menubar=no,toolbar=no');
} else {
alert("再见!");
}
} else {
alert("再见!");
}
}
</script>
</html>JavaScript入门篇
741709 学习 · 9869 问题
相似问题