Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

 
Reply to this topicStart new topic
> Stronicowanie w js
sleedz
post
Post #1





Grupa: Zarejestrowani
Postów: 43
Pomógł: 0
Dołączył: 15.01.2008

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


Witam.
Mam problem ze stronicowaniem w js. Problem polega na tym że lista stron się źle wyświetla w ie - wszystkie punkty się wyświetlają w jednym miejscu tzn jeden na drugim. W innych przeglądarkach jest wszystko ok tylko w ie się tak dzieje.

[JAVASCRIPT] pobierz, plaintext
  1. var li = '';
  2. for(var i=1; i<=sites; i++) {
  3. if(i==site) li += "<li class=\"active\" style=\"margin-right: 20px;\" id=\"s"+i+"\">"+i+"</li>";
  4. else li += "<li id=\"s"+i+"\" style=\"margin-left: 20px;\">"+i+"</li>";
  5. }
[JAVASCRIPT] pobierz, plaintext
Go to the top of the page
+Quote Post
nospor
post
Post #2





Grupa: Moderatorzy
Postów: 36 557
Pomógł: 6315
Dołączył: 27.12.2004




Z kodu co tu pokazałeś nic nie wynika
Temat: JavaScript jesli Twoj watek go dotyczy KONIECZNIE przeczytaj
Go to the top of the page
+Quote Post
sleedz
post
Post #3





Grupa: Zarejestrowani
Postów: 43
Pomógł: 0
Dołączył: 15.01.2008

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


Cała funkcja wygląda tak:
[JAVASCRIPT] pobierz, plaintext
  1. function cols(div_id, ii, col1, col2) {
  2.  
  3. var $div = $('#'+div_id+'1');
  4. if(ii==2) var $div2 = $('#'+div_id+'2');
  5. var orgWys =
  6. parseInt($div.css('height'));
  7. var next_col = "";
  8. $div.css('height', 'auto');
  9.  
  10. var tekst = new Array();
  11. var a ="";
  12. var j = 0;
  13. var i = 10;
  14. col1 = 0;
  15. col2 = 1;
  16. while(i>0) {
  17. var slowa = $div.html().split(' ');
  18. var ilosc = slowa.length;
  19. if ($div.height() > orgWys) {
  20.  
  21. var indeks = slowa.length;
  22. do {
  23. a = slowa.slice(0, --indeks).join(' ')
  24. $div.html(a);
  25.  
  26. } while ($div.height() > orgWys);
  27.  
  28. }
  29. tekst[j] = $div.html();
  30. next_col = slowa.slice(indeks, ilosc).join(' ');
  31. $div.html(next_col);
  32. if(!a) i=0;
  33.  
  34.  
  35. if(tekst[j].length == 0) i = 0;
  36. j++
  37.  
  38.  
  39. }
  40.  
  41. var l = tekst.length;
  42. $div.css('height', orgWys);
  43.  
  44. if(l>1) {
  45.  
  46. }
  47.  
  48. if(ii==2) {
  49. var sites = roundUp((l-1)/2)
  50. var li = '';
  51. var site = 1;
  52.  
  53. for(var i=1; i<=sites; i++) {
  54.  
  55. if(i==site) li += "<li class=\"active\" id=\"s"+i+"\">"+i+"</li>";
  56. else li += "<li id=\"s"+i+"\">"+i+"</li>";
  57. }
  58. $("#page_buttons ul").html(li);
  59.  
  60. for(var k=1; k<=sites; k++) {
  61. $("#s"+k).click(
  62. function() {
  63. var id = this.id.split('');
  64. site = id[1];
  65. var c1 = roundUp((site*2)-2);
  66. var c2 = roundUp((site*2)-1);
  67. $div.html(tekst[c1]);
  68. $div2.html(tekst[c2]);
  69. $("#page_buttons ul").children("li").removeClass();
  70. $(this).addClass("active");
  71. });
  72. }
  73.  
  74. $div.html(tekst[col1]);
  75. $div2.html(tekst[col2]);
  76. }
  77. if(ii==1) {
  78. var sites = roundUp(l-1)
  79. var li = '';
  80. //li += '<li style=\"margin-right: 20px;\">b</li>';
  81. var site = 1;
  82.  
  83. for(var x=1; x<=sites; x++) {
  84. if(i==site)
  85. li += "<li class=\"active\" style=\"margin-right: 20px;\" id=\"s"+x+"\">"+x+"</li>";
  86. else li += "<li id=\"s"+i+"\" style=\"margin-left: 20px;\">"+i+"</li>";
  87. }
  88. $("#page_buttons ul").html(li);
  89.  
  90. for(var k=1; k<=sites; k++) {
  91. $("#s"+k).click(
  92. function() {
  93. var id = this.id.split('');
  94. site = id[1];
  95. var c1 = site-1;
  96. $div.html("<div id=\"dc1text\">"+tekst[c1]);
  97. $("#page_buttons ul").children("li").removeClass();
  98. $(this).addClass("active");
  99. });
  100. }
  101.  
  102. $div.html(tekst[col1]);
  103. }
  104. }
[JAVASCRIPT] pobierz, plaintext


Kod html:
  1. <div id="col1">
  2. <div id="dc1text" style="margin-top: 30px;">TREŚĆ</div>
  3. </div>
  4. <div id="page_buttons">
  5. <ul></ul>
  6. </div>
  7.  
  8. <script type="text/javascript">
  9. window.onload=cols('col', 1);


Ten post edytował sleedz 2.12.2011, 09:56:26
Go to the top of the page
+Quote Post
nospor
post
Post #4





Grupa: Moderatorzy
Postów: 36 557
Pomógł: 6315
Dołączył: 27.12.2004




Czemu nie udostepnisz nam kodu online jak to masz napisane w linku co ci podalem?
Go to the top of the page
+Quote Post
sleedz
post
Post #5





Grupa: Zarejestrowani
Postów: 43
Pomógł: 0
Dołączył: 15.01.2008

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


http://www.browarmiejski.pl/about_us.html
Go to the top of the page
+Quote Post
nospor
post
Post #6





Grupa: Moderatorzy
Postów: 36 557
Pomógł: 6315
Dołączył: 27.12.2004




W ie nic na siebie nie na chodzi. W ie najzwyklej w świecie jest tylko jeden LI. No to mogłeś naprawdę sam sprawdzić.

ps: w ie na dzien dobry pojawi sie błąd js. Nie wiem czy to jego wina czy nie. Tobie się nie chciało analizować, mi tym bardziej (IMG:style_emoticons/default/smile.gif)
Go to the top of the page
+Quote Post
sleedz
post
Post #7





Grupa: Zarejestrowani
Postów: 43
Pomógł: 0
Dołączył: 15.01.2008

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


to nie jest wina tego błędu. ie po wykonaniu tej funkcji widzi że jest tylko jedna strona. ale nie wiem jak to rozwiązać
Go to the top of the page
+Quote Post

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

 



RSS Aktualny czas: 18.09.2025 - 12:25