<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>window.open</title>
<script type="text/javascript">
function Wopen(){
var mymessage=comfirm("你想知道慕课网怎么走么?");
if(mymessage==true)
window.open('http://www.imooc.com','_blank','width=600,height=400,top=100,left=0');
else
{alert("打开失败!");
}
</script>
</head>
<body>
<input name="button" type="button" onClick="Wopen()" value="点击我,打开新窗口!" / >
</body>
</html>
<!DOCTYPE HTML> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>window.open</title> <script type="text/javascript"> function Wopen(){ var mymessage=confirm("你想知道慕课网怎么走么?"); if(mymessage==true){ window.open('http://www.imooc.com','_blank','width=600,height=400,top=100,left=0')} else {alert("打开失败!"); } } </script> </head> <body> <input name="button" type="button" onClick="Wopen()" value="点击我,打开新窗口!" / > </body> </html>
confirm 你写成comfirm
function Wopen(){} 你缺了个大括号
这样就可以运行了^_^
没看来你把例子综合应用,挺会举一反三嘛。我也刚学,要不一起做个伴~
<script type="text/javascript">
function Wopen(){
var mymessage=confirm("你想知道慕课网怎么走么?");
if(mymessage==true){
window.open('http://www.imooc.com','_blank','width=600,height=400,top=100,left=0');}
else
{alert("打开失败!");
}
}
</script>
单词拼写错误confirm写成了comfirm, var mymessage=comfirm("你想知道慕课网怎么走么?");