一个javascript的问题

来源:百度知道 编辑:UC知道 时间:2024/05/10 14:59:09
我才学javascript,写了一个实现象IE地址栏一样的URL输入文本框,想实现在其中输入URL地址后,浏览器会转向输入的网站,但是总是无法实现,不知道问题在哪里?代码如:
<head>
<title>url title</title>
<script language="javascript">
function aswind()
{
aswind_url="http://"+window.document.aswind_form.aswind_test.value+"/";
window.open(aswind_url,"aswind_page",width='600' height='500'");
}
</script>
</head>

<body>
<form name="aswind_form" onsubmit="aswind();return false">
<h2>please enter the url<h2>
<input type="test" name="aswind_test" size=40 value="">
<input type=submit value="submit">
</form>

</body>

</html>
请懂的人帮我看看

window.open(aswind_url,"aswind_page",width='600' height='500'");
少了双引号了
改为:
window.open(aswind_url,"aswind_page","width='600' height='500'");

<input type=text id=url />
<input type=button value='go' onclick="gotoURL();" />
<script language=javascript>
function gotoURL(){
var url=document.getElementById("url").value;
if(url.toLowerCase().indexOf("http://")!=0)url="http://"+url;
window.open(url);
return;
}
</script>

所有源代码:

<htm1>

<body>
<input id="myUrl" type="test" size=40 value="">
<input type=submit value="submit" onClick="window.open('http://'+window.myUrl.value+'/');">
</body>

</html>

<head>