Jump to content

Recommended Posts

Posted

Encontrei um c贸digo base num site e alterei-o para um meu 馃槢

<html>
<body>
<HEAD>
<font face=verdana size=2 color=#1e90ff><SCRIPT LANGUAGE="JavaScript">
<!-- 
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 = (argc > 2) ? argv[2] : null;聽 
var path = (argc > 3) ? argv[3] : null;聽 
var domain = (argc > 4) ? argv[4] : null;聽 
var secure = (argc > 5) ? 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 DeleteCookie (name) {聽 
var exp = new Date();聽 
exp.setTime (exp.getTime() - 1);聽  
var cval = GetCookie (name);聽 
document.cookie = name + "=" + cval + "; expires=" + exp.toGMTString();
}
var expDays = 30;
var exp = new Date(); 
exp.setTime(exp.getTime() + (expDays*24*60*60*1000));
function amt(){
var count = GetCookie('count')
if(count == null) {
SetCookie('count','1')
return 1
}
else {
var newcount = parseInt(count) + 1;
DeleteCookie('count')
SetCookie('count',newcount,exp)
return count
聽  }
}
function getCookieVal(offset) {
var endstr = document.cookie.indexOf (";", offset);
if (endstr == -1)
endstr = document.cookie.length;
return unescape(document.cookie.substring(offset, endstr));
}
//聽 -->
</SCRIPT>
<BODY>
<SCRIPT LANGUAGE="JavaScript">
<!-- 
document.write("Voc锚 j谩 visitou <b>" + amt() + "</b> vezes.")
//聽 -->
</SCRIPT></font>

</body>
</html>

Espero que gostem deste contador das visitas de um s贸 utilizador.聽 馃槢

Our lives begin to end the day we become silent about things that matter - Martin Luther King

Posted

Sim 茅 uma das desvantagens do JavaScript. Mas eu curto muito fazer trabalhos nele, embora estou a mudar-me para o PHP 馃槢

Our lives begin to end the day we become silent about things that matter - Martin Luther King

  • 11 months later...
Posted

Sim podes por num ficheiro .js e depois importar mas basta ir ver de onde o file est谩 a ser importado e pronto 馃槢

I haven鈥檛 lost my mind; it鈥檚 backed up on DVD somewhere!

  • 7 months later...
Posted

RicardoC sabes ler o c贸digo?

Podia ter esse c贸digo no P@P, no Google, no Sapo, no Clix, na PTSec, onde quisesse que uns n茫o iam intervir em nada com os outros.

Our lives begin to end the day we become silent about things that matter - Martin Luther King

  • 1 year later...
Posted

O c贸digo sobe logo 2 visitas n茫o da para retirar isso? XD

Modificaste alguma coisa? Aquele c贸digo s贸 incrementa uma visita de cada vez...

Our lives begin to end the day we become silent about things that matter - Martin Luther King

  • 3 months later...
Posted

skin acho que nao percebeste a d煤vida dele.

Se tiveres um site em que todas as p谩ginas t锚m esse contador e se visitares 2 p谩ginas no mesmo site num curte espa莽o de tempo, o segundo click vai contar como uma segunda visita e ele n茫o quer isso.

A solu莽茫o a meu ver 茅 criar um intervalo curto em que se o utilizador voltar a visitar a p谩gina nesse espa莽o, o valor do cookie nao 茅 incrementado.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

By using this site you accept our Terms of Use and Privacy Policy. We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.