西安携程旅游网团购:一个javascript的问题

来源:百度文库 编辑:杭州交通信息网 时间:2024/04/28 09:32:37
我才学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>
<title>url title</title>
<script language="javascript">
function aswind()
{
var aswind_url="http://"+document.aswind_form.aswind_test.value+"/";
window.location.href="http://www.mysee.com";
}

</script>
</head>

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

</body>

</html>

你也简单的来写
如果你是想要新开的窗口的话:
function aswind()
{
aswind_url="http://"+window.document.aswind_form.aswind_test.value+"/";
alert(aswind_url);
window.open(aswind_url,'aswind_page',width='600',height='500');
}
两个错误:一个是onsubmit那用错了,你的return false;将函数效果取消了,第二个地方是window.open处,
这里:
http://www.770880.net/bbs/dispbbs.asp?boardid=7&id=83&page=1
有关于这个函数详细的解释

http://www.tiantiansoft.com/bbs/dispbbs.asp?boardID=54&ID=117076&page=1