问题描述
请问下面那个表格翻页图片时怎么返回顶部<!DOCTYPEHTMLPUBLIC"-//W3C//DTDHTML4.0Transitional//EN"><HTML><HEAD><TITLE>表格翻页</TITLE><style>body,td{font-size:9pt;}a:link{color:#FF0000;}a:visited{color:#FF0000;}a:hover{color:#006600;}</style><SCRIPTLANGUAGE="JavaScript"><!--varrecord=1;//每页显示多少条记录varcount=6;//记录总数varpageTotal=((count+record-1)/record)|0;//总页数varpagenum=1;//将要显示的页码Cookie={Set:function(){varname=arguments[0],value=escape(arguments[1]),days=365,path="/";if(arguments.length>2)days=arguments[2];if(arguments.length>3)path=arguments[3];with(newDate()){setDate(getDate()+days);days=toUTCString();}document.cookie="{0}={1};expires={2};path={3}".format(name,value,days,path);},Get:function(){varreturnValue=document.cookie.match(newRegExp("[b^;]?"+arguments[0]+"=([^;]*)(?=;|b|$)","i"));returnreturnValue?unescape(returnValue[1]):returnValue;}}String.prototype.format=function(){vartmpStr=this;variLen=arguments.length;for(vari=0;i<iLen;i++){tmpStr=tmpStr.replace(newRegExp("\{"+i+"\}","g"),arguments[i]);}returntmpStr;}functionsetPagenum(){//整理Cookiepagenum=Cookie.Get("pagenum");if(pagenum==""||pagenum<1){pagenum=1;}}setPagenum();//重新整理当前页码,如果页面小于1,则赋值为1,如果大于总页数,则等于总页数coordinatePagenum(pagenum);//根据当前要显示的页码取得当前面里第一条记录的号码varpageBegin=(record*(pagenum-1)+1)|0;//根据当前要显示的页码取得当前面里最后一条记录的号码varpageEnd=record*pagenum;functionshowhiddenRecord(pagenum){number.innerHTML=pagenum;if(pagenum<=1){theFirstPage.innerHTML="第一页";thePrePage.innerHTML="上一页";}else{theFirstPage.innerHTML="<ahref="javascript:firstPage()">第一页</a>";thePrePage.innerHTML="<ahref="javascript:prePage()">上一页</a>";}if(pagenum>=pageTotal){theNextPage.innerHTML="下一页";theLastPage.innerHTML="最后一页";}else{theNextPage.innerHTML="<ahref="javascript:nextPage()">下一页</a>";theLastPage.innerHTML="<ahref="javascript:lastPage()">最后一页</a>";}document.getElementById('goto').value=pagenum;//根据当前要显示的页码取得当前面里第一条记录的号码pageBegin=(record*(pagenum-1)+1)|0;//根据当前要显示的页码取得当前面里最后一条记录的号码pageEnd=record*pagenum;for(vari=1;i<=count;i++){if(i>=pageBegin&&i<=pageEnd){mytable.rows[i].style.display="";}else{mytable.rows[i].style.display="none";}}Cookie.Set("pagenum",pagenum);}functionfirstPage(){pagenum=1;showhiddenRecord(pagenum);}functionlastPage(){showhiddenRecord(pageTotal);}//重新整理当前页码,如果页面小于1,则赋值为1,如果大于总页数,则等于总页数functioncoordinatePagenum(num){if(num<1){num="1";}elseif(num>pageTotal){num=pageTotal;}}functionprePage(){pagenum--;coordinatePagenum(pagenum);showhiddenRecord(pagenum);}functionnextPage(){pagenum++;coordinatePagenum(pagenum);showhiddenRecord(pagenum);}functiongotoPage(num){coordinatePagenum(pagenum);showhiddenRecord(num);}//--></SCRIPT></HEAD><BODYonLoad="showhiddenRecord(pagenum)"><TABLEid="mytable"cellpadding=4cellspacing=1border=0bgcolor=#999999width=500align=center><TRbgcolor=#ffffff><TD>!</TD></TR><TRbgcolor=#ffffff><TD><imgsrc="http://coldpic.sfacg.com/Pic/OnlineComic4/WLHJ/049/001_9268.jpg"></TD></TR><TRbgcolor=#ffffff><TD><imgsrc="http://coldpic.sfacg.com/Pic/OnlineComic4/WLHJ/049/002_7089.jpg"></TD></TR><TRbgcolor=#ffffff><TD><imgsrc="http://coldpic.sfacg.com/Pic/OnlineComic4/WLHJ/049/003_2077.jpg"></TD></TR><TRbgcolor=#ffffff><TD><imgsrc="http://coldpic.sfacg.com/Pic/OnlineComic4/WLHJ/049/004_4530.jpg"></TD></TR><TRbgcolor=#ffffff><TD><imgsrc="http://coldpic.sfacg.com/Pic/OnlineComic4/WLHJ/049/005_4079.jpg"></TD></TR><TRbgcolor=#ffffff><TD><imgsrc="http://coldpic.sfacg.com/Pic/OnlineComic4/WLHJ/049/006_0599.jpg"></TD></TR></TABLE><br><br><center>共6页当前第<spanid="number">1</span>页<spanid="theFirstPage"><ahref="javascript:firstPage()">第一页</a></span><spanid="thePrePage"><ahref="javascript:prePage()">上一页</a></span><spanid="theNextPage"><ahref="javascript:nextPage()"target="_parent">下一页</a></span><spanid="theLastPage"><ahref="javascript:lastPage()">最后一页</a></span>转到第<selectonChange="gotoPage(this.value)"name="goto"><optionvalue=1>1</option><optionvalue=2>2</option><optionvalue=3>3</option><optionvalue=4>4</option><optionvalue=5>5</option><optionvalue=6>6</option></select>页</center></BODY><HTML>
解决方案
解决方案二:
在顶部设个锚点行不行
解决方案三:
functionnextPage(){pagenum++;coordinatePagenum(pagenum);showhiddenRecord(pagenum);document.body.scrollTop=0;//在翻页事件中加上这句试试}