输入的url必须是完整格式,怎么样才能自动匹配前缀http://
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>窗口</title>
<script type="text/javascript">
function openwindow(){
var queren = confirm("是否打开网页");
if(queren == true){
var wangzhi = prompt("请输入网址","http://www.imooc.com/");
if(wangzhi != null) {
window.open(wangzhi, "_blank", "width=600,height=400,top=200,left=400,menubar=no,toolbar=no,scrollbars=yes");
}else if(wangzhi == null){
alert("请输入网址!");
}
}else{
alert("谢谢!");
}
}
</script>
</head>
<body>
<input name="button" type="button" onclick="openwindow()" value="打开网址" />
</body>
</html>
如果输入框输入网址为www.imooc.com或者imooc.com代码会出错,哪位大神指导一下怎么解决