求一段网页制作的代码

来源:百度知道 编辑:UC知道 时间:2024/05/15 16:07:04
求一段代码,要求打开网页后有个数字输入框,输入数字后会自动跳转到一个含有这个数字的指定网页,如输入xxx就跳转到http://online.sh.cn_xxx.html,(xxx就是输入的数字)
可以把按钮去掉改成输入数字后按回车后在新的页面中打开这个连接,同时清除输入框中的内容吗?

<script>
function chk(){
window.location="http://online.sh.cn_"+form1.name.value+".html"
}
</script>
把上面的复制到</HEAD>上面
把下面的复制到<body>里面

<form action="" method="post" name="form1">
<input type="text" name="name" value="">
<input type="button" name="提交" onclick="chk()">
</form>