이 기사에서는 온라인 페이지의 마우스 클릭 수를 계산하는 JS 방법에 대해 설명합니다. 참조를 위해 공유하십시오. 특정 구현 방법은 다음과 같습니다.
코드를 다음과 같이 복사하십시오.
<html xmlns = "http://www.w3.org/1999/xhtml">
<헤드>
<title> js 마우스 </title>의 클릭 수를 기록합니다
<meta http-equiv = "content-type"content = "text/html; charset = gb2312">
</head>
<body>
<div id = "count"> </div> wulin.com www.vevb.com은 다음과 같습니다.
<script type = "text/javaScript">
기능 AddCookie (이름, CookieValue, Time) {
if (name! = ""&& cookievalue! = ""&& time! = "") {
if (isnan (time) == false) {
var 만료 = 새 날짜 ();
만료.
document.cookie = name + '=' + Escape (CookieValue) + '; 만료 =' + chepires.togmtstring ();
}
}
}
함수 getCookie (Cookiename) {
var cookiestring = document.cookie;
var start = cookiestring.indexof (Cookiename + '=');
if (start == -1)
널 리턴;
start + = cookiename.length + 1;
var end = cookiestring.indexof ( ';', start);
if (end == -1) unescape (Cookiestring.substring (start))을 반환합니다.
UNESCAPE를 반환합니다 (Cookiestring.Substring (시작, 끝));
}
var html = document.getElementsByTagName ( "html") [0];
html.onclick = function () {
var count = parseint (getCookie ( 'count'))+1;
AddCookie ( "count", count, "1000");
document.getElementById ( "count"). innerHtml = "당신은"+getCookie ( 'count')+"times!";
}
if (getCookie ( 'count')) {
document.getElementById ( "count"). innerHtml = "당신은"+getCookie ( 'count')+"times!";
}또 다른{
document.getElementById ( "count"). innerHtml = "아직 클릭하지 않았습니다!";
AddCookie ( "count", "0", "1000");
}
</스크립트>
</body>
</html>
이 기사가 모든 사람의 JavaScript 프로그래밍에 도움이되기를 바랍니다.