Pomoc - Szukaj - U¿ytkownicy - Kalendarz
Pe³na wersja: [JS] Skrypt Galerii nie dzia³a pod IE
Forum PHP.pl > Forum > Gotowe rozwi±zania
swmikolaj21
Mia³em dokonaæ kilku aktualizacji na stronie i jako¶ nagle przesta³a dzia³aæ galeria napisana w JS, a ja to zielony jestem w tym temacie i nie mogê dociec gdzie jest b³±d. W FF jest wszystko ok, tylko w IE nie dzia³aj± przyciski dalej (GalleryNext), wstecz itp

Za³±czam skrypt, mo¿e go znacie....

BêDê Wdziêczny za Pomoc smile.gif

strona galerii:
  1. <?php
  2. if (isset($_GET["id"]))
  3. $id = $_GET["id"];
  4. else
  5. $id = '1401';
  6. $langID = "pl";
  7. if (isset($_GET["lang"])) {
  8. $langID = $_GET["lang"];
  9. if ($langID != "pl" && $langID != "en" && $langID != "de")
  10. $langID = "pl";
  11. }
  12. $slajdy = "Slajdy";
  13. if ($langID == "de" || $langID == "en")
  14. $slajdy = "Slideshow";
  15. $powrot = "Powrót";
  16. switch ($langID) {
  17. case "en": $powrot = "Return"; break;
  18. case "de": $powrot = "Zurück"; break;
  19. }
  20. $sek = "sek.";
  21. if ($langID == "en")
  22. $sek = "sec.";
  23. ?>
  24. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
  25. <html>
  26. <head>
  27. <meta http-equiv="Content-type" content="text/html; charset=iso-8859-2">
  28. <meta http-equiv="Creation-date" content="2006-04-20T22:09:46Z">
  29. <meta http-equiv="Content-Language" content="pl">
  30. <link rel="stylesheet" href="galeria.css" type="text/css">
  31. <script type="text/javascript" src="page.js"></script>
  32. <script type="text/javascript" src="galeria.js"></script>
  33. <script type="text/javascript">
  34. <!--
  35. function DocumentInit() {
  36. GallerySetLanguage("<?php echo $langID ?>");
  37. GalleryInit();
  38. if (history.length == 0)
  39. document.getElementById("panel_powrot").disabled = true;
  40. }
  41.  
  42. function SetLang(lang) {
  43. window.location.href = "galeria.php?lang=" + lang + "&id=" + GalleryImageID();
  44. return false;
  45. }
  46. //-->
  47. </script>
  48. </head>
  49.  
  50. <body>
  51. <div id="midwrap">
  52. <div id="pagetop"></div>
  53. <div id="menu"><ul>
  54. <?php
  55. switch ($langID) {
  56. case "en":
  57. ?>
  58.  
  59. <?php break;
  60. case "de":
  61. ?>
  62.  
  63. <?php break;
  64. default:
  65. ?>
  66.  
  67. <?php } ?>
  68. <li id="flagi">
  69. <a id="polski" href="galeria.php?id=<?echo $id ?>&lang=pl" onClick='return SetLang("pl")'></a>
  70. <a id="deutsch" href="galeria.php?id=<?echo $id ?>&lang=de" onClick='return SetLang("de")'></a>
  71. <a id="english" href="galeria.php?id=<?echo $id ?>&lang=en" onClick='return SetLang("en")'></a>
  72. </li>
  73. </ul></div>
  74. <div id="content_wrap">
  75. <input id="guzik_lewy" type="button" value="«" class="guzik" onClick="GalleryPrev()">
  76. <input id="guzik_prawy" type="button" value="»" class="guzik" onClick="GalleryNext()">
  77. <img id="CurrentImage" src="img/full/foto<?php echo $id ?>.jpg" alt="Lata Yachts">
  78. <div id="panel">
  79. <input id="panel_lewo" type="button" value="«" class="guzik" onClick="GalleryPrev()">
  80. <input id="panel_slajdy" type="button" value="<?php echo $slajdy ?>" class="guzik" onClick="GalleryRunSlideshow()">
  81. <select id="panel_czas" onChange="GallerySetInterval()">
  82. <option value="3">3 <?php echo $sek ?></option>
  83. <option value="5" selected>5 <?php echo $sek ?></option>
  84. <option value="7">7 <?php echo $sek ?></option>
  85. <option value="10">10 <?php echo $sek ?></option>
  86. <option value="15">15 <?php echo $sek ?></option>
  87. </select>
  88. <input id="panel_powrot" type="button" value="<?php echo $powrot ?>" class="guzik" onClick="history.back()">
  89. <input id="panel_prawo" type="button" value="»" class="guzik" onClick="GalleryNext()">
  90. </div>
  91. </div>
  92.  
  93. </div>
  94. </body>
  95. </html>

Skrypt Galerii
  1. <?php
  2. var gallery1 = [
  3. "img/full/foto1472.jpg",
  4. "img/full/foto1401.jpg",
  5. "img/full/foto1.jpg",
  6. "img/full/foto3164.jpg",
  7. "img/full/foto1477.jpg",
  8. "img/full/foto1548.jpg",
  9. "img/full/foto2363.jpg",
  10. "img/full/foto1439.jpg",
  11. "img/full/foto1583.jpg",
  12. "img/full/foto1567.jpg",
  13. "img/full/foto1532.jpg",
  14. "img/full/foto1577.jpg",
  15. "img/full/foto1533.jpg"
  16. ];
  17. var gallery2 = ["img/full/foto10.jpg"];
  18. var gallery3 = [
  19. "img/full/foto31.jpg",
  20. "img/full/foto32.jpg",
  21. "img/full/foto33.jpg",
  22. "img/full/foto34.jpg",
  23. "img/full/foto2397.jpg",
  24. "img/full/foto0701.jpg",
  25. "img/full/foto0702.jpg",
  26. "img/full/foto0703.jpg",
  27. "img/full/foto0704.jpg",
  28. "img/full/foto0705.jpg",
  29. "img/full/foto0706.jpg",
  30. "img/full/foto0707.jpg",
  31. "img/full/foto0708.jpg",
  32. "img/full/foto0709.jpg",
  33. "img/full/foto0710.jpg",
  34. "img/full/foto0711.jpg",
  35. "img/full/foto0712.jpg",
  36. "img/full/foto0713.jpg",
  37. "img/full/foto0714.jpg",
  38. "img/full/foto0715.jpg",
  39. ];
  40. var gallery4 = [
  41. "img/full/foto21.jpg",
  42. "img/full/foto22.jpg",
  43. "img/full/foto23.jpg",
  44. "img/full/foto24.jpg",
  45. "img/full/foto25.jpg",
  46. "img/full/foto26.jpg",
  47. "img/full/foto27.jpg",
  48. "img/full/foto28.jpg",
  49. ];
  50. var gallery5 = [
  51. "img/full/foto0162.jpg",
  52. "img/full/foto0163.jpg",
  53. "img/full/foto0166.jpg",
  54. "img/full/foto0314.jpg",
  55. "img/full/foto0308.jpg",
  56. "img/full/foto0296.jpg",
  57. "img/full/foto0314.jpg",
  58. "img/full/foto0421.jpg",
  59. "img/full/foto0422.jpg",
  60. "img/full/foto0423.jpg",
  61. "img/full/foto0424.jpg",
  62. "img/full/foto0425.jpg",
  63. "img/full/foto0426.jpg",
  64. "img/full/foto0427.jpg",
  65. ];
  66. var galleries = [gallery1, gallery2, gallery3, gallery4, gallery5];
  67. var gallery = null;
  68. var galleryIdx = null;
  69. var slideInterval = null;
  70. var langID = "pl";
  71.  
  72. function GalleryImageID() {
  73. if (galleryIdx == null)
  74. return "1472";
  75. var img = gallery[galleryIdx];
  76. if (typeof img == "object")
  77. img = img.src;
  78. return img.replace(/^.*/img/full/foto(.+).jpg$/, "$1");
  79. }
  80.  
  81. function GalleryInit() {
  82. var curImg = document.getElementById("CurrentImage");
  83. var curName = curImg.src;
  84.  
  85. curName = curName.substr(curName.lastIndexOf("/") + 1);
  86. for (var j = 0; j < galleries.length && galleryIdx == null; ++j) {
  87. gallery = galleries[j];
  88. for (var i = 0; i < gallery.length; ++i)
  89. if (gallery[i].indexOf(curName) >= 0) {
  90. galleryIdx = i;
  91. gallery[i] = new Image();
  92. gallery[i].src = curImg.src;
  93. break;
  94. }
  95. }
  96. if (gallery.length == 1) {
  97. document.getElementById("guzik_lewy").disabled = true;
  98. document.getElementById("guzik_prawy").disabled = true;
  99. document.getElementById("panel_lewo").disabled = true;
  100. document.getElementById("panel_slajdy").disabled = true;
  101. document.getElementById("panel_czas").disabled = true;
  102. document.getElementById("panel_prawo").disabled = true;
  103. }
  104. GalleryPreload();
  105. }
  106.  
  107. function GalleryNext() {
  108. if (galleryIdx != null) {
  109. var i = galleryIdx + 1;
  110. if (>= gallery.length)
  111. = 0;
  112. GallerySelect(i);
  113. }
  114. }
  115.  
  116. function GalleryPreload() {
  117. if (galleryIdx != null) {
  118. var lastIdx = gallery.length - 1;
  119. var i = galleryIdx == lastIdx? 0 : galleryIdx + 1;
  120. var img = new Image();
  121.  
  122. img.onload = GallerySetPreload;
  123. if (typeof gallery[i] == "string") {
  124. img.src = gallery[i];
  125. gallery[i] = img;
  126. }
  127. else {
  128. = galleryIdx == 0? lastIdx : galleryIdx - 1;
  129. if (typeof gallery[i] == "string") {
  130. img.src = gallery[i];
  131. gallery[i] = img;
  132. }
  133. else {
  134. var stopIdx = i;
  135. = galleryIdx + 2;
  136. if (> lastIdx)
  137. -= lastIdx + 1;
  138. for (; i != stopIdx; i = i >= lastIdx? 0 : i + 1)
  139. if (typeof gallery[i] == "string") {
  140. img.src = gallery[i];
  141. gallery[i] = img;
  142. break;
  143. }
  144. }
  145. }
  146. }
  147. }
  148.  
  149. function GalleryPrev() {
  150. if (galleryIdx != null) {
  151. var i = (galleryIdx == 0? gallery.length : galleryIdx) - 1;
  152. GallerySelect(i);
  153. }
  154. }
  155.  
  156. function GalleryRunSlideshow() {
  157. if (slideInterval == null) {
  158. var msecs = parseInt(document.getElementById("panel_czas").value) * 1000;
  159. slideInterval = window.setInterval("GalleryNext()", msecs);
  160. document.getElementById("panel_slajdy").value = "Stop";
  161. }
  162. else
  163. GalleryStopSlideshow();
  164. }
  165.  
  166. function GallerySelect(idx) {
  167. var img = document.getElementById("CurrentImage");
  168. if (typeof gallery[idx] == "object")
  169. img.src = gallery[idx].src;
  170. else {
  171. var newImg = new Image();
  172. img.src = newImg.src = gallery[idx];
  173. gallery[idx] = newImg;
  174. }
  175. galleryIdx = idx;
  176. }
  177.  
  178. function GallerySetInterval() {
  179. if (slideInterval != null) {
  180. GalleryStopSlideshow();
  181. GalleryRunSlideshow();
  182. }
  183. }
  184.  
  185. function GallerySetLanguage(lang) {
  186. if (lang == "pl" || lang == "en" || lang == "de")
  187. langID = lang;
  188. }
  189.  
  190. function GallerySetPreload() {
  191. window.setTimeout("GalleryPreload()", 100);
  192. }
  193.  
  194. function GalleryStopSlideshow() {
  195. if (slideInterval != null) {
  196. window.clearTimeout(slideInterval);
  197. slideInterval = null;
  198. document.getElementById("panel_slajdy").value =
  199. langID == "pl""Slajdy" : "Slideshow";
  200. }
  201. }
  202. ?>


Kurcze, widzê, ¿e nikt nie wie, a czy mo¿ecie choæ poleciæ jakie¶ dobre forum o JS ?

Kurcze, widzê, ¿e nikt nie wie, a czy mo¿ecie choæ poleciæ jakie¶ dobre forum o JS ?
Babcia@Stefa
A czy niemorzesz napisaæ galeri w php, tylko akurat musi ona byæ w javascript?
Prosta galeria w php niewymaga ¿adnych bibliotek, je¶li chodzi o miniaturki to np. ustawiamy parametry wielko¶ci i szeroko¶ci w znaczniku html img.

Dziêkujê, Babcia@Stefa
kwiateusz
Przeniesiono:
Przedszkole->Gotowe rozwi±zania
To jest wersja lo-fi g³ównej zawarto¶ci. Aby zobaczyæ pe³n± wersjê z wiêksz± zawarto¶ci±, obrazkami i formatowaniem proszê kliknij tutaj.
Invision Power Board © 2001-2025 Invision Power Services, Inc.