<!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 mymessage=confirm("请问是否打开新网站?") ;
if(mymessage==true)
{var mychar=prompt("请输入网址:"," http://www.imooc.com/");
if(mychar!=null)
{ window.open("http://www.imooc.com","-blank","width=600px,height=400px,top=100px,left=100px")
}
else
{}
}
else
{
}
}
</script>
</head>
<body>
<input type="button" value="新窗口打开网站" onclick="openWindow()" />
</body>
</html>
因为你默认是慕课网的网址,所以不会打开别的网址,就没有给别的网址授权,虽然你可以输入别的网址,最终进入的都是慕课网
window.open(mychar,'_blank'。。。。。。。。)你好像把_blank打成了-blank
window.open(mychar,"-blank","width=600px,height=400px,top=100px,left=100px") 把网址直接改成mychar或者“mychar”,都没用,还是打不开输入的网址
把 输入的网址"mychar",给window.open(mychar);就好了
function openWindow(){ var mymessage=confirm("请问是否打开新网站?") ; if(mymessage==true){ var mychar=prompt("请输入网址:"," http://www.imooc.com/"); if(mychar!=null){ window.open(mychar,"-blank","width=600px,height=400px,top=100px,left=100px") } } }