主頁(yè) > 網(wǎng)站建設(shè) > 建站知識(shí) > 織夢(mèng)cms教程:實(shí)現(xiàn)按鍵盤方向鍵實(shí)現(xiàn)上一篇下一

織夢(mèng)cms教程:實(shí)現(xiàn)按鍵盤方向鍵實(shí)現(xiàn)上一篇下一

POST TIME:2020-04-02 13:48

這個(gè)功能在很多小說(shuō)站,圖片站經(jīng)常用到,大家可以留意一下,此教程源自于論壇熱心網(wǎng)友提供,下面來(lái)講講具體的修改操縱:

首先我們打開 include/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代碼就修改完了可以保存,接下來(lái)我們?cè)趦?nèi)容頁(yè)用js進(jìn)行調(diào)用.把以下代碼:

<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=bookpage
if (event.keyCode == 13) location = index_page
if (event.keyCode == 37) {
if (prevpage != '' && prevpage != '上一篇:沒有了 ') location = prevpage;
else alert('這是第一頁(yè)');
}
if (event.keyCode == 39) {
if (nextpage != '' && nextpage != '下一篇:沒有了 ') location = nextpage;
else alert('已經(jīng)是最后一頁(yè)了');
}
}
//-->
function getElement(aID) {
return (document.getElementById) ? document.getElementById(aID) : document.all[aID];
}
function makeRequest(url) {
http_request = false;
if (window.XMLHttpRequest) { //Mozilla,Safari,...
http_request = new XMLHttpRequest();
if (http_request.overrideMimeType) {
http_request.overrideMimeType('text/xml');
}
} else if (window.ActiveXObject) { //IE
try {
http_request = new ActiveXObject("Msxml2.XMLHTTP");
} catch(e) {
try {
http_request = new ActiveXObject("Microsoft.XMLHTTP");
} catch(e) {}
}
}
if (!http_request) {
alert('Giving up:(Cannot create an XMLHTTP instance)');
return false;
}
return http_request;
}
</script>


加到<body>之前的位置.這樣就全部修改完了,之后我們更新文檔看看效果。



收縮
  • 微信客服
  • 微信二維碼
  • 電話咨詢

  • 400-1100-266