为了账号安全,请及时绑定邮箱和手机立即绑定

请问怎么做到打开我想要去的网址

<!doctype html>
<html>
<head>
<meta charset="utf-8">
<script type="text/javascript">
function acc()
{
var hehe=confirm("确定打开窗口吗?");
if(hehe==true)
{var haha=prompt("请输入网址");
if(haha!=null)
{window.open("haha","_blank","width=300px,height=400px");}
else{}
}
else{}
}
</script>
<title>无标题文档</title>
</head>
<input type="button" name="button" value="点我" onClick="acc()"/>
<body>

</body>
</html>

我在window.open那里的网址设置了一个变量哈哈。  是我输入的prompt的值。  但是我输入百度的网址结果找不到网址。请问怎样才可以做到访问我输入的网址。 还是说window.open里的网址那里不可以使用变量?

正在回答

4 回答

{window.open("haha","_blank","width=300px,height=400px");}

改成

{window.open(haha,"_blank","width=300px,height=400px");}

0 回复 有任何疑惑可以回复我~

window.open("haha","_blank","width=300px,height=400px");}改为:window.open("url","_blank","width=300px,height=400px");}就可以啦


0 回复 有任何疑惑可以回复我~

haha改成你想去的网站,要包括http

0 回复 有任何疑惑可以回复我~

你输入的时候输入:http://www.baidu.com

0 回复 有任何疑惑可以回复我~

举报

0/150
提交
取消

请问怎么做到打开我想要去的网址

我要回答 关注问题
微信客服

购课补贴
联系客服咨询优惠详情

帮助反馈 APP下载

慕课网APP
您的移动学习伙伴

公众号

扫描二维码
关注慕课网微信公众号