請問怎麼實現網頁瀏覽記錄展示?_PHP教程

來源:互聯網
上載者:User
請問怎麼實現網頁瀏覽記錄展示?
答案
例如訊雷看看邊上的曆史觀看,還有一些新聞網站中的曆史點擊,有沒有這方面的案例?請指點,謝謝


其它解決方案
把url和頁面title儲存到cookies或者session
其它解決方案
用筆與本子,記下來....
其它解決方案
網上找到個用JS和COOKIE實現的,但不是很明白 function glog(evt) //定義紀錄滑鼠點擊動作的函數

{

evt=evt?evt:window.event;var srcElem=(evt.target)?evt.target:evt.srcElement;

try

{

while(srcElem.parentNode&&srcElem!=srcElem.parentNode)

//以上這個語句判斷滑鼠動作是否發生在有效地區,防止使用者的無效點擊也被紀錄下來

{

if(srcElem.tagName&&srcElem.tagName.toUpperCase()=="A")//判斷使用者點擊的對象是否屬於連結

{

linkname=srcElem.innerHTML; //取出事件發生源的名稱,也就是和之間的文字,也就是連結名稱哈

address=srcElem.href+"_www.achome.cn_"; //取出事件發生源的href值,也就是該連結的地址

wlink=linkname+"+"+address; //將連結名稱和連結地址整合到一個變數當中

old_info=getCookie("history_info"); //從Cookies中取出以前紀錄的瀏覽曆史,該函數後面有聲明

//以下程式開始判斷新的瀏覽動作是否和已有的前6個曆史重複,如果不重複則寫入cookies

var insert=true;

if(old_info==null) //判斷cookie是否為空白

{

insert=true;

}

else

{

var old_link=old_info.split("_www.achome.cn_");

for(var j=0;j<=5;j++)

{

if(old_link[j].indexOf(linkname)!=-1)

insert=false;

if(old_link[j]=="null")

break;

}

}



if(insert)

{

wlink+=getCookie("history_info");

setCookie("history_info",wlink); //寫入cookie,該函數後面有聲明

history_show().reload();

break;

}



}

srcElem = srcElem.parentNode;

}

}

catch(e){}

return true;

}

function getCookieVal (offset) {

var endstr = document.cookie.indexOf (";", offset);

if (endstr == -1) endstr = document.cookie.length;

return unescape(document.cookie.substring(offset, endstr));

}



function getCookie (name) {

var arg = name + "=";

var alen = arg.length;

var clen = document.cookie.length;

var i = 0;

while (i < clen) {

var j = i + alen;

if (document.cookie.substring(i, j) == arg) return getCookieVal (j);

i = document.cookie.indexOf(" ", i) + 1;

if (i == 0) break;

}

return null;

}



//將瀏覽動作寫入cookie

function setCookie (name, value) {

var exp = new Date();

exp.setTime (exp.getTime()+3600000000);

document.cookie = name + "=" + value + "; expires=" + exp.toGMTString();

}

function history_show()

{

var history_info=getCookie("history_info"); //取出cookie中的記錄

var content=""; //定義一個顯示變數

if(history_info!=null)

{

history_arg=history_info.split("_www.achome.cn_");

var i;

for(i=0;i<=5;i++)

{

if(history_arg[i]!="null")

{

var wlink=history_arg[i].split("+");

content+=("↑"+""+wlink[0]+"
");

}

document.getElementById("history").innerHTML=content;

}

}

else

{document.getElementById("history").innerHTML="對不起,您沒有任何瀏覽紀錄";}

}[/i][/i]


複製代碼
其它解決方案
做個標記這個對我有用。
其它解決方案
用筆與本子,記下來....
於安 發表於 2008-6-3 11:13 [url=http://bbs.phpchina.com/redirect.php?goto=findpost&pid=459164&ptid=64656]連結標記[img]http://bbs.phpchina.com/images/common/back.gif[/img][/url]
屢試不爽的好辦法!
其它解決方案
媽的,現在才知道是挖出來的古屍。。。

http://www.bkjia.com/PHPjc/632381.htmlwww.bkjia.comtruehttp://www.bkjia.com/PHPjc/632381.htmlTechArticle請問怎麼實現網頁瀏覽記錄展示? 答案 例如訊雷看看邊上的曆史觀看,還有一些新聞網站中的曆史點擊,有沒有這方面的案例?請指點,...

  • 聯繫我們

    該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

    如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.