| | |
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 34 Days Ago
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: 552
Reputation:
Solved Threads: 64
0
#4 33 Days Ago
•
•
•
•
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; 33 Days Ago 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: 552
Reputation:
Solved Threads: 64
0
#6 32 Days Ago
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 32 Days Ago
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; 32 Days Ago 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
acid2 ajax ajaxexample ajaxjspservlets array beta blackjack boarder box browser captcha captchaformproblem cart close codes column css date debugger decimal dependent design developer disablefirebug dom download element embed engine enter error events ext file firefox flash focus form frameworks game getselection google gwt gxt hiddenvalue highlightedword hint html ie7 iframe index java javascript javascripthelp2020 jquery jsp libcurl listbox maps marquee masterpage media menu mimic mp4 onerror onmouseoutdivproblem onmouseover parameters paypal pdf php position post problem programming prototype rated rating redirect safari scale scriptlets scroll search security select size software starrating synchronous toggle tweet unicode variables w3c webservice window windowofwords xml






