고유 한 히트/클릭 카운터가 ip에서 작동합니다.jquery hit counter
진부의 수를 표시하려면 body 태그에 onload 함수를 사용합니다. 예를 들어 : (프랑스어)
<body class="homepage" onload="affiche_compteur('compteur1'); affiche_compteur('compteur2');affiche_compteur('compteur3');affiche_compteur('compteur4');affiche_compteur('compteur5');affiche_compteur('compteur6');">
affiche_compteur = display_counter는
내 HTML 페이지에서 클릭 할 때마다 카운터 현재 온로드와 함께 호출해야합니다. (하드 코딩 된 요소에 대해 작동하지만, 제 경우에는 HTML 페이지 (하드 코드되지 않은)에 존재하지 않는 문서 준비 요소를 추가했습니다.)
클릭 카운터의 모든 ID를 얻는 방법은 있습니까? 각 카운터 onload?
여기 내 아약스 스크립트 : 여기
function getXhr(){
var xhr = null;
if(window.XMLHttpRequest) {
xhr = new XMLHttpRequest();
} else if(window.ActiveXObject) {
try {
xhr = new ActiveXObject("Msxml2.XMLHTTP");
} catch (e) {
xhr = new ActiveXObject("Microsoft.XMLHTTP");
}
} else {
alert("Votre navigateur ne supporte pas les objets XMLHTTPRequest...");
xhr = false;
}
return xhr;
};
function affiche_compteur(id_clics)
{
var xhr = getXhr();
xhr.onreadystatechange = function()
{
if(xhr.readyState == 4 && xhr.status == 200){
document.getElementById(id_clics).innerHTML = xhr.responseText;
}
};
xhr.open('POST', './compteur/affiche_compteur.php', true);
xhr.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
xhr.send('compteurId='+id_clics);
}
클릭 요소에 대한 HTML : 내 영어
<div class="element blog " id="_13">
<a class="link" href="/portfolio/dock.html" onclick="gestionClic('compteur13');">
</a>
</div>
<div class="element blog " id="_12">
<a class="link" href="/portfolio/dock.html" onclick="gestionClic('compteur12');">
</a>
</div>
<div class="element blog " id="_11">
<a class="link" href="/portfolio/dock.html" onclick="gestionClic('compteur11');">
</a>
</div>
미안 해요, 프랑스입니다.
그냥 호기심
: 당신이 jQuery를 사용하는 경우, 당신은 왜 자신의 XHR 롤 않으며 jQuery를'아약스()'구현을 사용하지 않는? – Steve
잘 모르겠습니다 ... PHP 스크립트를 읽을 수 있도록이 글을 씁니다. ip가 존재하지 않으면 데이터베이스에 증가 된 클릭 수를 기록하십시오 ... – lolo