qq_PureBLACK_13313525
2016-05-08 11:26
<!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 sb=confirm("确认要打开网站?")
if(sb==true)
{var sp=prompt("是否要打开此网页",http://www.imooc.com/)
if(sp==true)
{window.open("http://www.imooc.com/","_blank","width=400px","height=500px","munebar=no","toolbar=no")}
else
{alert("再见")}
}
else
{alert("再见")}
</script>
</head>
<body>
<input type="button" value="新窗口打开网站" onclick="openWindow()" />
</body>
</html>
confirm的{}大括号里面,弹出我看前面介绍的是document.write
window.open()括号里面是单引号
<!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 sb=confirm("确认要打开网站?");
if(sb==true)
{
var sp=prompt("是否要打开此网页","http://www.imooc.com/"); //逗号错了,用了全角的,下面一些符号也是,另外语句末尾要加分号
if(sp!=null)
/*
这里不能用“sp==true”,因为其返回值为:
1. 点击确定按钮,文本框中的内容将作为函数返回值
2. 点击取消按钮,将返回null
*/
{window.open("http://www.imooc.com/","_blank","width=400px,height=500px,munebar=no,toolbar=no");}
else
{alert("再见");}
}
else
{alert("再见");}
}
</script>
</head>
<body>
<input type="button" value="新窗口打开网站" onClick="openWindow()" />
</body>
</html>
<head>
<title> new document </title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<script type="text/javascript">
function openWindow(){
var sb=confirm("确认要打开网站?")
if(sb=true)
{
window.open("http://www.imooc.com/","_blank","width=400,height=500,munebar=no,toolbar=no")}
else
{
alert("再见")
}
}
</script>
</head>
<body>
<input type="button" value="新窗口打开网站" onclick="openWindow()" />
</body>
</html>
JavaScript入门篇
742055 学习 · 9869 问题
相似问题