上岸洗澡的鱼 发表于 2012-4-18 10:47:08

织梦DEDECMS网站实现按键盘方向键上一篇下一篇翻页的功能

今天给大家讲的是织梦dede模板网站实现按键盘方向键上一篇下一篇翻页的功能,其实在很多小说站,图片站都有这个功能,就是看书看图片的时候可以直接使用键盘方向键来实现翻页功能,其实方法也还算很简单。
打开 include/arc.archives.class.php 查找到以下代码:$this->PreNext["pre"] = "上一篇:{$preRow["title"]} ";
替换成以下代码:
$this->PreNext["pre"] = "$mlink ";$this->PreNext["next"] = "下一篇:{$nextRow["title"]} ";
然后在内容页用js进行调用,代码如下:


function getElement(aID)
{
return (document.getElementById) ? document.getElementById(aID): document.all;
}
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;
}

                                    
         
加入到文章模版的标签之前的内容就行了,当然为了防止页面代码臃肿,大家可以将此代码放在JS文件中调用即可,保持页面清爽。
呵呵!
页: [1]
查看完整版本: 织梦DEDECMS网站实现按键盘方向键上一篇下一篇翻页的功能