先看一代码js按键盘方向键代码代码如下<SCRIPT language=>document.onkeydown = pageEvent;var prevpage="https://www.111cn.net/";var nextpage="https://www.111cn.net/";function pageEvent(evt){evt = evt ||window.event;var key=evt.which||evt.keyCode;if (key == 37) location = prevpageif (key == 39) location = nextpage};</SCRIPT>说明:按键盘← →方向键 或 PageUp PageDown键直接翻页
好了说远下面进入正题。首先我们打开 /arc.archives.class.php 查找到以下代码:代码如下:$this->PreNext['pre'] = "上一篇:<a href='$mlink'>{$preRow['title']}</a> "; $this->PreNext['pre'] = "$mlink ";替换成以下代码:$this->PreNext['next'] = "下一篇:<a href='$mlink'>{$nextRow['title']}</a> ";这样php代码就修改完了可以保存,接下来我们在内容页用js进行调用.把以下代码:
下面我们在模板页面中如下操作:代码如下<script type="text/javascript" language="javascript"><!--document.onkeydown=nextpage;var prevpage='{dede:prenext get='pre'/}';var nextpage='{dede:prenext get='next'/}';var index_page = "index.html";//var bookpage="index.html";function nextpage(event){eventevent = event ? event : (window.event ? window.event : null);//if (event.keyCode==13) location=bookpageif (event.keyCode==13) location=index_pageif (event.keyCode==37){if (prevpage!='' && prevpage!='上一篇:没有了 ')location=prevpage;elsealert('这是第一页');}if (event.keyCode==39){if (nextpage!='' && nextpage!='下一篇:没有了 ')location=nextpage;elsealert('已经是最后一页了');}}//-->function getElement(aID){return (document.getElementById) ? document.getElementById(aID): document.all[aID];}</script>