Mam taki kodzik:
  1. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  2. <html xmlns="http://www.w3.org/1999/xhtml">
  3. <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  4. <title>With Cookies</title>
  5. <script type="text/javascript" language="javascript" src="/js/jquery-1.4.2.min.js"></script>
  6. <script type="text/javascript" language="javascript" src="/js/jquery.cookie.js"></script>
  7. <script type="text/javascript" language="javascript">
  8. $(document).ready(function() {
  9. // LEFT COLUMN:
  10. // When the collapse button is clicked:
  11. $('.collapseLeft').click(function() {
  12. $('.collapseLeft').css("display","none");
  13. $('.expandLeft').css("display","block");
  14. $('#leftCol').animate( {height:"20px"}, {duration:400} );
  15. $.cookie('leftCol', 'collapsed');
  16. });
  17. // When the expand button is clicked:
  18. $('.expandLeft').click(function() {
  19. $('.expandLeft').css("display","none");
  20. $('.collapseLeft').css("display","block");
  21. $('#leftCol').animate( {height:"500px"}, {duration:400} );
  22. $.cookie('leftCol', 'expanded');
  23. });
  24. // RIGHT COLUMN:
  25. // When the collapse button is clicked:
  26. $('.collapseRight').click(function() {
  27. $('.collapseRight').css("display","none");
  28. $('.expandRight').css("display","block");
  29. $('#rightCol').animate( {height:"20px"}, {duration:400} );
  30. $.cookie('rightCol', 'collapsed');
  31. });
  32. // When the expand button is clicked:
  33. $('.expandRight').click(function() {
  34. $('.expandRight').css("display","none");
  35. $('.collapseRight').css("display","block");
  36. $('#rightCol').animate( {height:"500px"}, {duration:400} );
  37. $.cookie('rightCol', 'expanded');
  38. });
  39. // COOKIES
  40. // Left column state
  41. var leftCol = $.cookie('leftCol');
  42. // Right column state
  43. var rightCol = $.cookie('rightCol');
  44. // Set the user's selection for the left column
  45. if (leftCol == 'collapsed') {
  46. $('.collapseLeft').css("display","none");
  47. $('.expandLeft').css("display","block");
  48. $('#leftCol').css("height","20px");
  49. };
  50. // Set the user's selection for the right column
  51. if (rightCol == 'collapsed') {
  52. $('.collapseRight').css("display","none");
  53. $('.expandRight').css("display","block");
  54. $('#rightCol').css("height","20px");
  55. };
  56. });
  57. body {
  58. background-color:#444444;
  59. position:relative;
  60. }
  61. #page {
  62. width:500px;
  63. margin:0 auto;
  64. text-align:center;
  65. background-color:#222222;
  66. padding:1px;
  67. }
  68. #leftCol {
  69. width:149px;
  70. margin-right:1px;
  71. height:500px;
  72. float:left;
  73. background-color:#666666;
  74. position:relative;
  75. }
  76. #rightCol {
  77. width:350px;
  78. height:500px;
  79. float:left;
  80. background-color:#333333;
  81. position:relative;
  82. }
  83. .expandLeft, .expandRight {
  84. width:11px;
  85. height:11px;
  86. background:url(http://www.shopdev.co.uk/blog/expand.gif) no-repeat;
  87. position:absolute;
  88. right:5px;
  89. top:4px;
  90. display:none;
  91. }
  92. .collapseLeft, .collapseRight {
  93. width:11px;
  94. height:11px;
  95. background:url(http://www.shopdev.co.uk/blog/collapse.gif) no-repeat;
  96. position:absolute;
  97. right:5px;
  98. top:4px;
  99. }
  100. </head>
  101.  
  102. <div id="page">
  103. <div id="leftCol">
  104. <div class="collapseLeft"></div>
  105. <div class="expandLeft"></div>
  106. </div>
  107. <div id="rightCol">
  108. <div class="collapseRight"></div>
  109. <div class="expandRight"></div>
  110. </div>
  111. <br clear="all" />
  112. </div>
  113. </body>
  114. </html>


i chcę, aby domyślnie było rowinięte i w tym: <div class="informacja">tekst</div> i nie wiem gdzie to wkleić. Bardzo proszę o pomoc.

Jak ustwić domyślnie expand i gdzie wkleić div?

EDIT:
Postanowiłem zmienić kod, lecz nie działają mi w nim ciasteczka.
Co jest nie tak 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>