名站网址导航为大驾家提供DedeCMS站点程序站点教程相关的知识,比如织梦程序安装教程,织梦程序系统故障等教程。
//读写cookie系统数据库函数 functionGetCookie(c_name) { if(document.cookie.length>0) { c_start=document.cookie.indexOf(c_name "=") if(c_start!=-1) { c_start=c_start c_name.length 1; c_end=document.cookie.indexOf(";",c_start); if(c_end==-1) { c_end=document.cookie.length; } return(document.cookie.substring(c_start,c_end)); } } returnnull } functionSetCookie(c_name,value,expiredays) { varexdate=newDate(); exdate.setDate(exdate.getDate() expiredays); document.cookie=c_name "=" escape(value) ((expiredays==null)?"":";expires=" exdate.toGMTString());//使设置的有效时间正确。增加toGMTString() } |
增加一个系统数据库函数。
如下:
functiongetCookies(ids,title,img){ varsaveid=GetCookie('id'); varsavetitle=GetCookie('products'); varsaveimg=GetCookie('images'); if(saveid!=null&&savetitle!=null&&saveimg!=null) { varsaveids=saveid.split(','); varsavetitles=savetitle.split(','); varsaveimgs=saveimg.split(','); varhasid=false; saveid=''; savetitle=''; saveimg=''; j=1; for(i=saveids.length-1;i>=0;i--) { if(saveids[i]==ids&&hasid)continue; else{ if(saveids[i]==ids&&!hasid)hasid=true; saveid =(saveid==''?saveids[i]:',' saveids[i]); savetitle =(savetitle==''?savetitles[i]:',' savetitles[i]); saveimg =(saveimg==''?saveimgs[i]:',' saveimgs[i]); j ; if(j==10&&hasid)break; if(j==9&&!hasid)break; } } if(hasid){returnfalse;} elsesaveid =',' ids; savetitle =',' title; saveimg =',' img; SetCookie('id',saveid,1); SetCookie('products',savetitle,1); SetCookie('images',saveimg,1); } else { SetCookie('id',ids,1); //这个是ID。用来做链接用的 SetCookie('products',title,1); //这个是文章标题,用来显示在页面的 SetCookie('images',img,1); //这个是图片 } } |
<scriptlanguage="javascript"type="text/javascript"src="{dede:global.cfg_cmsurl/}/include/js/dedeajax2.js"></script> <scriptlanguage="javascript"type="text/javascript"> getCookies({dede:field.id/},'{dede:field.title/}','{dede:field.litpic/}') functionCheckLogin2(){ vartaget_obj=document.getElementByIdx_x_x('_userlogin'); myajax=newDedeAjax(taget_obj,false,false,'','',''); myajax.SendGet2("{dede:global.cfg_cmspath/}/member/ajax_loginsta2.php"); DedeXhTTP=null; } </script> |
2.在模板页面引用js.
具体调用历史记录的相关具体代码如下:
<divclass="Recommendh-394"> <h1class="rec-bg"><spanclass="span-rt-3"><aonclick="destroy_cookie()">清空</a></span>最近浏览过的课程</h1> <ulclass="w-223browse"id="viewhistory"> <scripttype="text/javascript"> functiondestroy_cookie(){ SetCookie('id','',1); SetCookie('products','',1); SetCookie('images','',1); document.getElementByIdx_x_x('viewhistory').innerhTML=""; window.alert('你已成功清除浏览历史记录!'); } </script> <scripttype="text/javascript"> varsaveid=GetCookie('id'); varsavetitle=GetCookie('products'); varsaveimg=GetCookie('images'); if(saveid!=null&&savetitle!=null) { varsaveids=saveid.split(','); varsavetitles=savetitle.split(','); varsaveimgs=saveimg.split(','); varhasid=false; saveid=''; savetitle=''; saveimg=''; for(i=saveids.length-1;i>=0;i--) { document.write("<li>" "<divclass='w-53'><ahref="/plus/view.php?aid=" saveids[i] ""title="" savetitles[i] ""><imgsrc='" saveimgs[i] "'width='52'height='51'/></a></div><pclass='w-53-rt'><ahref="/plus/view.php?aid=" saveids[i] ""title="" savetitles[i] "">" savetitles[i] "</a></p></li>"); } } </script> </ul> </div> |
关于DedeCMS站点程序站点教程相关的知识,就说到这里了希望能帮助朋友们。织梦程序“更新系统系统缓存”清理沉积系统缓存的功能