skin Posted July 24, 2006 at 01:23 PM Report #39926 Posted July 24, 2006 at 01:23 PM 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
Drone Posted July 24, 2006 at 03:11 PM Report #39965 Posted July 24, 2006 at 03:11 PM Nice 馃槢 good work, apesar de eu preferir faze-lo em PHP 馃槢 nao gosto de c贸digo que esteja exposto ao "publico" lol
skin Posted July 24, 2006 at 06:27 PM Author Report #40014 Posted July 24, 2006 at 06:27 PM 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
diogo.delgaudio Posted June 30, 2007 at 12:28 PM Report #111515 Posted June 30, 2007 at 12:28 PM se nao me engano acho que existe maneira de colocar o codigo JS fora do HTML, acho que ja vi algo assim. - Roger that.<br />- Affirmative.
magician Posted June 30, 2007 at 12:57 PM Report #111518 Posted June 30, 2007 at 12:57 PM 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!
RicardoC Posted February 10, 2008 at 01:37 PM Report #165830 Posted February 10, 2008 at 01:37 PM S贸 uma pergunta eu tenho dezenas de p谩ginas.....como poderia colocar este contador, para que as contagens n茫o ficassem alteradas de acordo com o site
skin Posted February 10, 2008 at 01:40 PM Author Report #165832 Posted February 10, 2008 at 01:40 PM 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
der Posted June 15, 2009 at 05:21 PM Report #272456 Posted June 15, 2009 at 05:21 PM O c贸digo sobe logo 2 visitas n茫o da para retirar isso? XD
skin Posted June 15, 2009 at 06:38 PM Author Report #272475 Posted June 15, 2009 at 06:38 PM 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
jarsantos Posted September 20, 2009 at 05:42 AM Report #287898 Posted September 20, 2009 at 05:42 AM 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.
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now