<!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 flag;
flag= confirm("是否打开新网站");
if(flag=true){
var myUrl= prompt("请输入要打开的网址","");
if(null!=myUrl){
window.open('http://'+myUrl,'_blank','width=400,height=500');
}
else
window.open('http://www.taobao.com','_blank','width=400,height=500');
}
}
</script>
</head>
<body>
<input type="button" value="新窗口打开网站" onclick="openWindow()" />
</body>
</html>
我运行的的话淘宝网站能打开,把flag=true改成flag==true,前者的是赋值,后者的是相等
function openWindow(){
var flag;
flag= confirm("是否打开新网站");
if(flag == true){
var myUrl= prompt("请输入要打开的网址");
if(myUrl !=null){
window.open(myUrl,"_blank","width=400,height=500");
}
else{
window.open('https://www.taobao.com/','_blank','width=400,height=500');
}
}
}