В этой статье описывается метод JS для расчета количества щелчков мыши на странице онлайн. Поделитесь этим для вашей ссылки. Конкретный метод реализации следующим образом:
Скопируйте код следующим образом: <! Doctype html public "-// w3c // dtd xhtml 1.0 transitional // en" "http://www.w3.org/tr/xhtml1/dtd/xhtml1-transitional.dtd">
<html xmlns = "http://www.w3.org/1999/xhtml">
<голова>
<title> JS Записывает количество кликов на мыши </title>
<meta http-equiv = "content-type" content = "text/html; charset = gb2312">
</head>
<тело>
<div id = "count"> </div> wulin.com www.vevb.com подсказывает вам:
<script type = "text/javascript">
Функция addCookie (имя, cookieivalue, time) {
if (name! = "" && cookieivalue! = "" && time! = "") {
if (isnan (время) == false) {
var истекает = новая дата ();
истекает.settime (истекает.gettime () + время * 1000);
document.cookie = name + '=' + escape (cookieivalue) + '; истекает =' + expires.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 (Start, End));
}
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");
}
</script>
</body>
</html>
Я надеюсь, что эта статья будет полезна для каждого программирования JavaScript.