shuilinbo - 2013/5/2 15:06:16
v2.1中 有没有自己最近浏览记录?自定义模块如何调用? 就是 自己刚才浏览过哪些文章 按顺序在左侧显示。
xiyou - 2013/5/2 15:39:26
没有这种功能
可以用js的cookie功能来保存你最近打开过过的文章id,然后通过ajax模型中获取这些id来读取列表,思路大致就这样,具体代码自己写,不过3.0才有ajax模型,2.1只有自己写aspx文件来读取了。
shuilinbo - 2013/5/2 18:27:46
在网上查到一个js 测试下可以。。。拿出来和大家分享。。首先要打开url重写 我启用的是aspx
然后在你想调用的页面 加入下面的代码:
<fieldset id="www_Mangbaobao_Com">未找到您最近浏览过的网页 </fieldset> <script type="text/javascript">
//<![CDATA[
if(navigator.cookieEnabled){//判断是否支持Cookie
var tag = document.getElementById("www_Mangbaobao_Com");//输出结果DIV id
var N = 20;//太长标题截取汉字字数
var listCount = 15;//记录和显示最近几条
var myTitle = escape(document.title) + "^";//取标题
var myUrl = escape(location.pathname) + "$";//取地址
var expTime = new Date(new Date().setDate(new Date().getDate() + 500));//设定过期时间为500天
var edp = "|; expires=" + expTime.toGMTString() + "; path=/";//组合Cookie参数
var allCookie = document.cookie;//取出全部Cookie
if(allCookie.indexOf("news=") != -1 || allCookie.indexOf("$|") != -1){//判断是否为第一次浏览
var myCookieStart = allCookie.indexOf("news=") + "news=".length;
var myCookieEnd = allCookie.indexOf("$|",myCookieStart);
var myCookieall = unescape(allCookie.substring(myCookieStart,myCookieEnd));
var myCookie = myCookieall.split("$");
var myCookieTit = new Array();
var myCookieUrl = new Array();
for(var i = 0; i < myCookie.length; i++){
var myCookieOne = myCookie.split("^");
myCookieTit = myCookieOne[0];
myCookieUrl = myCookieOne[1];
}
var tagDat = "";
for(var i =myCookieTit.length - 1; i >= 0; i--){//从先到后顺序取得结果值
var textCount = myCookieTit.replace(/[^\x00-\xff]/g,"aa").length;
if(textCount <= N*2){
texts = myCookieTit;
}else{
for(var a = N; a < textCount; a++){
texts = myCookieTit.substr(0,a);
if(texts.replace(/[^\x00-\xff]/g,"aa").length >= N*2){
texts += "..."
break;
}
}
}
tagDat += "<a href=\"" + myCookieUrl + "\"" + " title=\"" + myCookieTit + "\"target=_blank>" + texts + "</a><br>"
}
tag.innerHTML =tagDat;//输出结果给页面div
var newCookie = "";
if(myCookie.length < listCount){
for(i in myCookie){
if(myCookieTit == document.title) continue;//去除重复
newCookie += escape(myCookieTit) + "^" + escape(myCookieUrl) + "$" ;
}
}else{
for(var i = 1; i < listCount; i++){
if(myCookieTit == document.title) continue;
newCookie += escape(myCookieTit) + "^" + escape(myCookieUrl) + "$" ;
}
}
document.cookie = "news=" + newCookie + myTitle + myUrl + edp;
}else{
document.cookie = "news="+ myTitle + myUrl + edp;
}
}else{//不支持Cookie的处理
tag.innerHTML="您的浏览器关闭了Cookie功能,不能为您自动保存最近浏览过的网页!"
}
//]]>
</script>