功能描述:当用户在一个文本输入框中输入某个数字(只能输入数字!),然后点击文本框后的"go"按钮,页面跳转到输入的数字页面.问题:需要一段实现该功能的javascript代码.That's all..
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>é¿å®å·¥ä½å®¤ - ä¿¡æ¯æ示</title>
<style type="text/css">
table { font-size: 12px; }
</style>
<SCRIPT language=javascript>
var secs=3;//3ç§
for(i=1;i<=secs;i++)
{ window.setTimeout("update(" + i + ")", i * 1000);}
function update(num)
{
if(num == secs)
{ self.location.href=' http://www.abaonet.com/';; }
else
{ }
}
</SCRIPT>
</head>
<body>
<br>
<br>
<br>
<br>
<br>
<br>
<table width="500" border="0" align="center" cellpadding="3" cellspacing="1" bgcolor="#8080A6">
<tr>
<td height="25"><div align="center"><strong><font color="#FFFFFF">é¿å®å·¥ä½å®¤ - æ示信æ¯ï¼</font></strong></div></td>
</tr>
<tr bgcolor="#FFFFFF">
<td height="80"><div align="center"> <br>
<b>æ¨è®¿é®ç页é¢å¯è½å·²è¢«æ´æ¹ï¼æ£å¨è½¬å主页......</b> <br>
<br>
<a href= http://www.abaonet.com/>å¦ææ¨çæµè§å¨æ²¡æèªå¨è·³è½¬ï¼è¯·ç¹å»è¿é</a> <br>
<br>
</div></td>
</tr>
</table>
</body>
</html>
å¦ä¸é¢ç代ç ï¼ä½ å¦å为 .html çæ ¼å¼ï¼å°±å¯ä»¥çåºææäºã
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>é¿å®å·¥ä½å®¤ - ä¿¡æ¯æ示</title>
<style type="text/css">
table { font-size: 12px; }
</style>
<SCRIPT language=javascript>
var secs=3;//3ç§
for(i=1;i<=secs;i++)
{ window.setTimeout("update(" + i + ")", i * 1000);}
function update(num)
{
if(num == secs)
{ self.location.href=' http://www.abaonet.com/';; }
else
{ }
}
</SCRIPT>
</head>
<body>
<br>
<br>
<br>
<br>
<br>
<br>
<table width="500" border="0" align="center" cellpadding="3" cellspacing="1" bgcolor="#8080A6">
<tr>
<td height="25"><div align="center"><strong><font color="#FFFFFF">é¿å®å·¥ä½å®¤ - æ示信æ¯ï¼</font></strong></div></td>
</tr>
<tr bgcolor="#FFFFFF">
<td height="80"><div align="center"> <br>
<b>æ¨è®¿é®ç页é¢å¯è½å·²è¢«æ´æ¹ï¼æ£å¨è½¬å主页......</b> <br>
<br>
<a href= http://www.abaonet.com/>å¦ææ¨çæµè§å¨æ²¡æèªå¨è·³è½¬ï¼è¯·ç¹å»è¿é</a> <br>
<br>
</div></td>
</tr>
</table>
</body>
</html>
å¦ä¸é¢ç代ç ï¼ä½ å¦å为 .html çæ ¼å¼ï¼å°±å¯ä»¥çåºææäºã
温馨提示:答案为网友推荐,仅供参考
第1个回答 2013-08-08
<script language="javascript">
function page_go()
{
var p=document.getElementById("pageIndex").value
if(p!=""&&!isNaN(p)) //如果输入的页码不为空且为数字,则重定向页面并传递页码参数
{
location.href="test.asp?page="+p;
}
}
</script>
<form id="form1" method="post">
<input type="text" name="pageIndex" id="pageIndex" onkeypress="return event.keyCode>=48&&event.keyCode<=57" /><!--限制只能输入数字-->
<input type="button" name="myButton" value="go" onclick="page_go();" />
</form>
function page_go()
{
var p=document.getElementById("pageIndex").value
if(p!=""&&!isNaN(p)) //如果输入的页码不为空且为数字,则重定向页面并传递页码参数
{
location.href="test.asp?page="+p;
}
}
</script>
<form id="form1" method="post">
<input type="text" name="pageIndex" id="pageIndex" onkeypress="return event.keyCode>=48&&event.keyCode<=57" /><!--限制只能输入数字-->
<input type="button" name="myButton" value="go" onclick="page_go();" />
</form>
第2个回答 2013-08-08
<script language="javascript">
function ck()
{window.location.href=document.getElementById("textid").value+".htm"</p><p>}
</script>
<form id="form1" name="form1" method="post" action="">
<input type="text" name="textfield" id="textid" />
<input type="button" name="botton" value="提交" onclick="return ck()" />
</form>
function ck()
{window.location.href=document.getElementById("textid").value+".htm"</p><p>}
</script>
<form id="form1" name="form1" method="post" action="">
<input type="text" name="textfield" id="textid" />
<input type="button" name="botton" value="提交" onclick="return ck()" />
</form>