Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> [JavaScript]Wywołanie funkcji
stefik4
post
Post #1





Grupa: Zarejestrowani
Postów: 176
Pomógł: 1
Dołączył: 18.11.2007

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


Witam posiadam funkcje JS którą chaiał bym aby uruchamiała się wrac z załadowaniem strony. Próbowałem body onload ale nie działa ;/

Spróbowałem wpisać nazwę i też nic:

  1. <script type="text/javascript">
  2. var dialogWidth = 300;
  3. var dialogHeight = 200;
  4. var timeout = 10000;
  5. function showModal(dW, dH)
  6. {
  7. var dialogDiv = document.getElementById("dialogDiv");
  8. var transparentDiv = document.getElementById("transparentDiv");
  9.  
  10. if(!dialogDiv) return;
  11. if(!transparentDiv) return;
  12. if(!dW) var dW = dialogWidth;
  13. if(!dH) var dH = dialogHeight;
  14.  
  15. dialogDiv.style.width = dW + "px";
  16. dialogDiv.style.height = dH + "px";
  17.  
  18. var clientWidth = parseInt(document.documentElement.clientWidth);
  19. var clientHeight = parseInt(document.documentElement.clientHeight);
  20. var scrollHeight = parseInt(document.documentElement.scrollHeight);
  21. var scrollWidth = parseInt(document.documentElement.scrollWidth);
  22.  
  23. transparentDiv.style.width = Math.max(scrollWidth, clientWidth) + "px";
  24. transparentDiv.style.height = Math.max(scrollHeight, clientHeight) + "px";
  25.  
  26. var left = Math.floor((clientWidth - dW) / 2);
  27. var top = Math.floor((clientHeight - dH) / 2);
  28.  
  29. dialogDiv.style.top = top -400+ "px";
  30. dialogDiv.style.left = left + "px";
  31.  
  32. dialogDiv.style.display = "block";
  33. transparentDiv.style.display = "block";
  34. }
  35. function closeModal()
  36. {
  37. var dialogDiv = document.getElementById("dialogDiv");
  38. var transparentDiv = document.getElementById("transparentDiv");
  39.  
  40. if(!dialogDiv) return;
  41. if(!transparentDiv) return;
  42.  
  43. dialogDiv.style.display = "none";
  44. transparentDiv.style.display = "none";
  45. }
  46. showModal(500,280);
  47. </script>


A gdy w treści strony dodam odnośnik: <a href="#" onclick="showModal(550, 290);">.</a> to funkcja otworzy okno i jest okej.
Go to the top of the page
+Quote Post

Posty w temacie


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 Aktualny czas: 20.08.2025 - 18:04