Home > Backend Development > PHP Tutorial > How to display web browsing history? _PHP Tutorial

How to display web browsing history? _PHP Tutorial

WBOY
Release: 2016-07-13 10:53:45
Original
1046 people have browsed it




How to display web browsing history?
Answer
For example, Xunlei looks at the historical views on the side, and the historical clicks on some news websites. Are there any cases in this regard? Please give me some advice, thank you


Other solutions
Save the url and page title to cookies or session
Other solutions
Use a pen and a notebook to write it down....
Other solutions
I found one on the Internet that uses JS and COOKIE, but I don’t quite understand it. function glog(evt) //Define a function that records mouse clicks

{

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

try

{

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

//The above statement determines whether the mouse action occurs in a valid area to prevent the user's invalid clicks from being recorded

{

if(srcElem.tagName&&srcElem.tagName.toUpperCase()=="A")//Determine whether the object clicked by the user is a link

{

linkname=srcElem.innerHTML; //Get the name of the event source, which is the text between and, which is the link name

address=srcElem.href+"_www.achome.cn_"; //Get the href value of the event source, which is the address of the link

wlink=linkname+"+"+address; //Integrate the link name and link address into one variable

old_info=getCookie("history_info"); //Get the previously recorded browsing history from Cookies. There is a statement after this function

//The following program starts to determine whether the new browsing action is the same as the previous 6 historical ones. If it is not repeated, cookies will be written

var insert=true;

if(old_info==null) //Determine whether the cookie is empty

{

insert=true;

}

else

{

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

for(var j=0;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); //Write cookie, there is a statement after this function

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
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;

}



//Write browsing actions into 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"); //Get the history record in the cookie

var content=""; //Define a display variable

if(history_info!=null)

{

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

var i;

for(i=0;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="Sorry, you don't have any browsing history";}

}[/i][/i]


Copy code
Other solutions
Mark this worked for me.
Other solutions
Use a pen and a notebook to write it down....
Yu An published on 2008-6-3 11:13 [url=http://bbs.phpchina.com/redirect.php?goto=findpost&pid=459164&ptid=64656]Link tag [img]http://bbs.phpchina. com/images/common/back.gif[/img][/url]
A good method that has been tried and tested!
Other solutions
Damn it, now I know it’s an ancient corpse that was dug up. . .

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/632381.htmlTechArticleHow to display web browsing records? Answer: For example, take a look at the historical views on Xunlei and the historical clicks on some news websites. Are there any cases in this regard? Please give me some advice...
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template