Tuesday, September 22, 2009

Setting cookies and updating cookies and reading cookies in javascript

Cookies reading and cookie updating function in javascript the code follows for cookie reading and cookie updating and cookie creating this funciton will increase the numbers in cookie and reset the number cookies and read the inoformation from the cookie script

document.cookie ='ckcount=0; expires=Thu, 3 Aug 2010 20:47:11 UTC; path=/';

document.cookie ='ackcount=0; expires=Thu, 3 Aug 2010 20:47:11 UTC; path=/';

//document .getElementById ('ctl00_ContentPlaceHolder1_imageid').src=quote[0];

function sss()

{

var x = readCookie('ckcount');

// alert (x);

if(x!=null )

{

x++;

document.cookie ='ckcount='+x+'; expires=Fri, 3 Aug 2010 20:47:11 UTC; path=/';

if(x>4)

{ document.cookie ='ckcount=0; expires=Fri, 3 Aug 2010 20:47:11 UTC; path=/';

}

document .getElementById ('ctl00_ContentPlaceHolder1_imageid').src=quote[x];

 

}

else

{

document.cookie ='1'

}

}

function advsss()

{

//

var x = readCookie('ackcount');

//alert (x);

if(x!=null )

{

x++;

document.cookie ='ackcount='+x+'; expires=Fri, 3 Aug 2010 20:47:11 UTC; path=/';

if(x>10)

{ document.cookie ='ackcount=0; expires=Fri, 3 Aug 2010 20:47:11 UTC; path=/';

}

document .getElementById ('ctl00_ContentPlaceHolder1_image2').src=quote1[x];

//alert (quote1[x]);

}

else

{

document.cookie ='1'

}

}

function readCookie(name) {

var nameEQ = name + "=";

var ca = document.cookie.split(';');

for(var i=0;i < ca.length;i++) {

var c = ca[i];

while (c.charAt(0)==' ') c = c.substring(1,c.length);

if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);

}

return null;

}

function sss1()

{

var x = readCookie('ckcount');

//alert (x);

if(x!=null )

{

x--;

if(x>10

x<=0)

{ document.cookie ='ckcount=0; expires=Fri, 3 Aug 2010 20:47:11 UTC; path=/';

x=0;

}

document.cookie ='ckcount='+x+'; expires=Fri, 3 Aug 2010 20:47:11 UTC; path=/';

document .getElementById ('ctl00_ContentPlaceHolder1_imageid').src=quote[x];

}

else

{

document.cookie ='0'

}

}

function advsss1()

{

var x = readCookie('ackcount');

//alert (x);

if(x!=null )

{

x--;

if(x>10

x<=0)

{ document.cookie ='ackcount=0; expires=Fri, 3 Aug 2010 20:47:11 UTC; path=/';

x=0;

}

document.cookie ='ackcount='+x+'; expires=Fri, 3 Aug 2010 20:47:11 UTC; path=/';

document .getElementById ('ctl00_ContentPlaceHolder1_image2').src=quote1[x];

}

else

{

document.cookie ='0'

 

}

}

No comments:

Post a Comment