: : SCRIPTS HELP : :  O Futuro do Web Design
 

 

 

:: Principal
 :: Downloads
 :: Apostilas
 :: Tutoriais
 :: ASP
 :: CGI
 :: CSS
 :: DHTML

 :: FLASH

 :: JAVA
 :: JAVA APPLET

 :: CURSO HTML
 :: CURSO JAVA SCRIPT
 :: PHP
 :: Destaques
 :: Script do mês


 

 

 :: Concurso
 :: Anuncie

 :: Parceria
 :: Fale Conosco
 :: Tire sua Dúvida

 

 

 

 

 

 

 

 

 

 

 

<<< voltar

:: JAVA SCRIPT ::                          

 

Java Script - Contador de Acessos


Descrição:
Este script cria um  contador pessoal para você colocar em sua home page. É muito legal pois você poderá colocar as mensagens de boas vindas que mais lhe agradarem, e assim o seu visitante saberá quantas vezes ele já visitou o seu site.

 

Passo1: Copie o código abaixo e cole dentro da seção <head> da sua página:

<script language="JavaScript">

<!-- Hide this script from old browsers --
/*
Script de contador de visitas 
scriptshelp - O SEU PORTAL 
WWW.SCRIPTSHELP.HPG.COM.BR
*/
var expdate = new Date();
var visits3;
var tracking=false;
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 < clen) 
{
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;
}
function SetCookie (name, value) 
{
var argv = SetCookie.arguments;
var argc = SetCookie.arguments.length;
var expires = (2 < argc) ? argv[2] : null;
var path = (3 < argc) ? argv[3] : null;
var domain = (4 < argc) ? argv[4] : null;
var secure = (5 < argc) ? argv[5] : false;
document.cookie = name + "=" + escape (value) +
((expires == null) ? "" : ("; expires=" + expires.toGMTString())) +
((path == null) ? "" : ("; path=" + path)) +
((domain == null) ? "" : ("; domain=" + domain)) +
((secure == true) ? "; secure" : "");
}
function displayInfo()
{
tracking=true;
// Set expiration date to a year from now.
expdate.setTime(expdate.getTime() + (24 * 60 * 60 * 1000 * 365)); 
if(!(visits3 = GetCookie("visits3"))) 
visits3 = 0;
visits3++;
SetCookie("visits3", visits3, expdate, "/", null, false);
welcomeWindow = window.open("", "welcomeWindow", "width=400,height=220");
welcomeWindow.document.write("<HTML><BODY bgcolor=white text=#000000><BR><center><STRONG>");
welcomeWindow.document.write("<FONT face=Arial>Você já visitou essa página<BR><FONT COLOR=darkblue size =5>"+visits3+"</FONT><BR>vez(es).</FONT></STRONG></center>");
if(visits3 == 1) 
welcomeWindow.document.write("<P><FONT SIZE=+2><EM><CENTER><STRONG>Seja Bem Vindo</STRONG></CENTER></EM></FONT>");
if(visits3 == 2) 
welcomeWindow.document.write("<P><FONT SIZE=+2><EM><CENTER><STRONG>Você voltou, obrigado</STRONG></CENTER></EM></FONT>");
if(visits3 == 3) 
welcomeWindow.document.write("<P><FONT SIZE=+2><EM><CENTER><STRONG>Nossa, é você novamente</STRONG></CENTER></EM></FONT>");
if(visits3 == 4) 
welcomeWindow.document.write("<P><FONT SIZE=+2><EM><CENTER><STRONG>Parece que você esta gostando da minha HP</STRONG></CENTER></EM></FONT>");
if(visits3 == 5) 
welcomeWindow.document.write("<P><FONT SIZE=+2><EM><CENTER><STRONG>Você aqui novamente? É, você gostou!!!</STRONG></CENTER></EM></FONT>");
if(visits3 == 6) 
welcomeWindow.document.write("<P><FONT SIZE=+2><EM><CENTER><STRONG>Cara, você está aumentando o meu contador</STRONG></CENTER></EM></FONT>");
welcomeWindow.document.write("<CENTER><FORM><INPUT TYPE='button' VALUE='Fechar' onClick='window.close()'></FORM></CENTER></BODY></HTML>");
}
// Sets count of cookie 'visits3' to zero.
function resetCounter()
{
var expdate = new Date();
expdate.setTime(expdate.getTime() + (24 * 60 * 60 * 1000 * 365)); 
visits3 = 0;
SetCookie("visits3", visits3, expdate , "/", null, false);
}
// -->
</script>

Passo2: Copie o código abaixo e cole dentro da seção <body> de sua página, no local aonde você deseja ver os botões "Olhar Contador" e "Resetar Contador":

<!------------------------------- Script Recomeça Aqui -------------------------------->

<form>
<div align="center"><center><p><input TYPE="button" VALUE="Olhar Contador"
onClick="displayInfo()"> <input TYPE="button" VALUE="Resetar contador"
onClick="resetCounter()"> </p>
</center></div>
</form>

<!------------------------------- Script Termina Aqui -------------------------------->