<html>
<head>
<meta charset="utf-8">
<title>打开新网页</title>
<script type="text/javascript">
function wopen(){
var mess =confirm("确认要打开新窗口吗");
if(mess==true){
var _url = prompt("请输入要的开的网址","http://www.immc.com");
window.open(_url,"_blank");}
else
{alert("再见")}
}
</script>
</head>
<body>
<input type="button" value="新窗口打开网站" onClick="wopen()"/>
</body>
</html>
<html> <head> <meta charset="utf-8"> <title>打开新网页</title> <script type="text/javascript"> function wopen(){ var _url; var mess =confirm("确认要打开新窗口吗"); if(mess==true){ _url = prompt("请输入要的开的网址","http://www.immc.com"); window.open(_url,"_blank");} else {alert("再见")} } </script> </head> <body> <input type="button" value="新窗口打开网站" onClick="wopen()"/> </body> </html> 符号问题
<html>
<head>
<meta charset="utf-8">
<title>打开新网页</title>
<script type="text/javascript">
function wopen(){
var url;
var mess =confirm("确认要打开新窗口吗");
if(mess==true){
url = prompt("请输入要的开的网址","http://www.immc.com");
if(url=="http://www.immc.com"){
window.open('url','_blank');
}}
else
{alert("再见")}
}
</script>
</head>
<body>
<input type="button" value="新窗口打开网站" onClick="wopen()"/>
</body>
</html>
你的代码是没有问题的,你试试用你的本地编辑器试一试,我用huBuilder是可以打开的
<html>
<head>
<meta charset="utf-8">
<title>打开新网页</title>
<script type="text/javascript">
function wopen(){
var mess =confirm("确认要打开新窗口吗");
if(mess==true){
var _url = prompt("请输入要的开的网址");
if(_url=="http://www.immc.com"){
window.open('_url','_blank');
}
}
else
{alert("再见")}
}
</script>
</head>
<body>
<input type="button" value="新窗口打开网站" onClick="wopen()"/>
</body>
</html>
var url = prompt("请输入要的开的网址","http://www.immc.com");
window.open(url,"_blank");}
我把下划线删了,还有请输入网址后面的逗号你好像不是英文输入的