| | |
Cookies with javascript
Please support our JavaScript / DHTML / AJAX advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
![]() |
•
•
Join Date: Aug 2009
Posts: 5
Reputation:
Solved Threads: 0
Hi I have made a program in which we have to read cookies through javascript but I am facing a problem in it. And I am unable to understand where the problem is? Please help me understand the same.
JavaScript / DHTML / AJAX Syntax (Toggle Plain Text)
<html> <head> <title>read cookies</title> <script language="javascript"> function gettime(){ if(document.cookie) { index=document.cookie.indexOf(cookie_name); if(index!=-1) countbegin=(documnet.cookie.indexOf("=",index); countend=document.cookie.indexOf(";",index); if(countend == -1) countend=document.cookie.length; } count=document.cookie.substring(countbegin,countend); if(count==1) return(count+"time"); } else { return(count+ "times"); } }} return("0 times"); } </script> </head> </html>
-1
#2 Nov 11th, 2009
Java and JavaScript are not the same. Post moved to JavaScript section
Learn to see in another's calamity the ills which you should avoid.
Publilius Syrus
(~100 BC)
LJC - London Java Community, Graduate & Undergraduate Software Development Community, JAVAWUG (Java Web User Group), The London Android Group
Publilius Syrus
(~100 BC)
LJC - London Java Community, Graduate & Undergraduate Software Development Community, JAVAWUG (Java Web User Group), The London Android Group
•
•
Join Date: Sep 2009
Posts: 557
Reputation:
Solved Threads: 64
0
#4 Nov 12th, 2009
•
•
•
•
Hi I have made a program in which we have to read cookies through javascript but I am facing a problem in it. And I am unable to understand where the problem is? Please help me understand the same.
JavaScript / DHTML / AJAX Syntax (Toggle Plain Text)
<html> <head> <title>read cookies</title> <script language="javascript"> function gettime(){ if(document.cookie) { index=document.cookie.indexOf(cookie_name); if(index!=-1) countbegin=(documnet.cookie.indexOf("=",index); countend=document.cookie.indexOf(";",index); if(countend == -1) countend=document.cookie.length; } count=document.cookie.substring(countbegin,countend); if(count==1) return(count+"time"); } else { return(count+ "times"); } }} return("0 times"); } </script> </head> </html>
Use the proper indentation, it will help to debug the code.
Starting braces '{' are 3 and the ending braces '}' are 6
Last edited by network18; Nov 12th, 2009 at 4:24 am.
"The discipline of writing something down is the first step towards making it happen."
follow me on twitter
follow me on twitter
•
•
Join Date: Sep 2009
Posts: 557
Reputation:
Solved Threads: 64
0
#6 Nov 12th, 2009
just clear those braces and post your code again, what you using in the script
"The discipline of writing something down is the first step towards making it happen."
follow me on twitter
follow me on twitter
•
•
Join Date: Aug 2009
Posts: 5
Reputation:
Solved Threads: 0
0
#7 Nov 12th, 2009
JavaScript / DHTML / AJAX Syntax (Toggle Plain Text)
<html> <head> <title>read cookies</title> <script language="javascript"> function gettime() { if(document.cookie) { index=document.cookie.indexOf(cookie_name); if(index!=-1) { countbegin=(document.cookie.indexOf("=",index); countend=document.cookie.indexOf(";",index); if(countend == -1) countend=document.cookie.length; } count=document.cookie(countbegin,countend); if(count==1) return(count+"time"); } else { return(count+ "times"); } return("0 times"); } </script> </head> </html>
Last edited by namratakakkar84; Nov 12th, 2009 at 7:26 am.
![]() |
Similar Threads
- cross browser javascript capatibility problems (JavaScript / DHTML / AJAX)
- cookie problem with iframe and different domain (ASP)
- Tracking user visits (JavaScript / DHTML / AJAX)
- how use iframes in a form (JSP)
- Scrollbar position on refresh problem (JavaScript / DHTML / AJAX)
- Floating IP Address in AOL (PHP)
- log in script saves cookie (JavaScript / DHTML / AJAX)
- IE6,SVPK1 not allowing entrance to Excite (Web Browsers)
Other Threads in the JavaScript / DHTML / AJAX Forum
- Previous Thread: onmouseover not working in ie
- Next Thread: Dynamic table rows
| Thread Tools | Search this Thread |
Tag cloud for JavaScript / DHTML / AJAX
ajax ajaxexample ajaxjspservlets array autoplay blackjack browser captchaformproblem checkbox child class close codes date debugger dependent developer disablefirebug dom editor element embed engine events explorer ext file firefox flash form forms game gears getselection google gxt hiddenvalue highlightedword hint html ie7 ie8 iframe internet java javascript javascripthelp2020 jquery jsf jsfile jsp jump libcurl maps marquee masterpage math matrixcaptcha media mysql object onerror onmouseoutdivproblem onreadystatechange parent passing paypal pdf php player position post programming rated redirect runtime safari scriptlets scroll search security session shopping size software solutions star stars stretch synchronous toggle tweet unicode variables web webkit webservice window wysiwyg \n






