In diesem Artikel wird die Methode von JS beschrieben, um die Anzahl der Mausklicks in einer Seite online zu berechnen. Teilen Sie es für Ihre Referenz. Die spezifische Implementierungsmethode lautet wie folgt:
Kopieren Sie den Code wie folgt: <! 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">
<kopf>
<titels> js zeichnen Sie die Anzahl der Klicks auf die Maus </title> auf
<meta http-äquiv = "content-type" content = "text/html; charSet = gb2312">
</head>
<body>
<div id = "count"> </div> wulin.com www.vevb.com fordert Sie auf:
<script type = "text/javaScript">
Funktion addoCookie (Name, Cookievalue, Zeit) {
if (name! = "" && cookievalue! = "" && time! = "") {
if (isnan (Zeit) == false) {
var ablehnt = neues Datum ();
läuft.settime (abläuft.getTime () + Zeit * 1000);
document.cookie = name + '=' + Escape (cookievalue) + '; expires =' + abläuft.togmtstring ();
}
}
}
Funktion getcookie (Cookiename) {
var cookiestring = document.cookie;
var start = cookiestring.indexof (Cookiename + '=');
if (start == -1)
null zurückkehren;
Start + = Cookiename.Length + 1;
var end = cookiestring.indexof (';', start);
if (end == -1) return unemission (cookiestring.substring (start));
Return Unscape (Cookiestring.Substring (Start, Ende));
}
var html = document.getElementsByTagName ("html") [0];
html.onclick = function () {
var count = parseInt (getcookie ('count'))+1;
addookie ("count", count, "1000");
document.getElementById ("count"). innerhtml = "Sie klickte"+getcookie ('count')+"Times!";
}
if (getcookie ('count')) {
document.getElementById ("count"). innerhtml = "Sie klickte"+getcookie ('count')+"Times!";
}anders{
document.getElementById ("count"). innerhtml = "Sie haben noch nicht darauf geklickt!";
addookie ("count", "0", "1000");
}
</script>
</body>
</html>
Ich hoffe, dieser Artikel wird für JavaScript -Programme aller hilfreich sein.