Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

 
Reply to this topicStart new topic
> Problem z ciasteczkami, Co jest nie tak z ciasteczkami?
PiotrN
post 28.09.2010, 16:25:52
Post #1





Grupa: Zarejestrowani
Postów: 73
Pomógł: 0
Dołączył: 8.05.2010

Ostrzeżenie: (0%)
-----


Co jest nie tak z ciasteczkami w poniższym kodzie?

  1. <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
  2. <title>two state cookie</title>
  3. <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
  4. <style type="text/css">
  5. <!--
  6. #setup {
  7. color:#000;
  8. background-color:#fff;
  9. }
  10. #info {
  11. width:400px;
  12. padding:30px 20px;
  13. border:3px double #000;
  14. margin:20px auto;
  15. }
  16. #info p {
  17. margin:0;
  18. text-align:justify;
  19. }
  20. .hide {
  21. display:none;
  22. }
  23. .show {
  24. display:block;
  25. }
  26. -->
  27.  
  28. <script type="text/javascript">
  29. <!--
  30. var state;
  31. window.onload=function() {
  32. obj=document.getElementById('info');
  33. state=(state==null)?'hide':state;
  34. obj.className=state;
  35.  
  36. document.getElementById('setup').onclick=function() {
  37. obj.className=(obj.className=='show')?'hide':'show';
  38. state=obj.className;
  39. setCookie();
  40. return false;
  41. }
  42. }
  43.  
  44. function setCookie() {
  45. exp=new Date();
  46. plusMonth=exp.getTime()+(31*24*60*60*1000);
  47. exp.setTime(plusMonth);
  48. document.cookie='State='+state+';expires='+exp.toGMTString();
  49. }
  50.  
  51. function readCookie() {
  52. if(document.cookie) {
  53. state=document.cookie.split('State=')[1];
  54. }
  55. }
  56. readCookie();
  57. //-->
  58.  
  59. </head>
  60.  
  61. <div>
  62. <a id="setup" href="#">show/hide information</a>
  63. </div>
  64.  
  65. <div id="info">
  66. <p>
  67. Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Proin massa. Nam vehicula.
  68. Morbi velit nisi, mollis id, ultrices luctus, adipiscing sit amet, lectus. Nunc rhoncus
  69. nisl ac enim. Maecenas vestibulum dolor ut velit. Maecenas condimentum pulvinar purus.
  70. Pellentesque ac ipsum. Curabitur sodales, elit vel molestie hendrerit, elit odio rhoncus tellus,
  71. nec gravida enim urna id velit. Donec nec tellus. Vestibulum nulla. Curabitur enim arcu,
  72. ornare id, placerat eget, nonummy vitae, mauris. Nulla rutrum semper odio. Duis vulputate
  73. ornare mauris. Praesent eget nibh sed ante ultricies scelerisque. Duis eget felis ut arcu porta
  74. bibendum. Mauris rutrum. Vivamus consectetuer purus sit amet mi. Suspendisse eu augue.
  75. </p>
  76. </div>
  77.  
  78. </body>
  79. </html>
Go to the top of the page
+Quote Post
IceManSpy
post 28.09.2010, 18:21:15
Post #2





Grupa: Zarejestrowani
Postów: 1 006
Pomógł: 111
Dołączył: 23.07.2010
Skąd: Kraków

Ostrzeżenie: (0%)
-----


A co ma być z nimi? Nie mają smaku? Jak tak, to może dopraw je funkcja setCookie, bo nigdzie nie przyprawiasz. Wiesz tylko, ze czego ta przyprawa jest zrobiona.


--------------------
Go to the top of the page
+Quote Post

Reply to this topicStart new topic
1 Użytkowników czyta ten temat (1 Gości i 0 Anonimowych użytkowników)
0 Zarejestrowanych:

 



RSS Wersja Lo-Fi Aktualny czas: 14.08.2025 - 01:08