需要一段实现页数跳转的代码

功能描述:当用户在一个文本输入框中输入某个数字(只能输入数字!),然后点击文本框后的"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 的格式,就可以看出效果了。
温馨提示:答案为网友推荐,仅供参考
第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>
第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>

相关了解……

你可能感兴趣的内容

本站内容来自于网友发表,不代表本站立场,仅表示其个人看法,不对其真实性、正确性、有效性作任何的担保
相关事宜请发邮件给我们
© 非常风气网