Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> [JS] problem z wywołaniem funkcji
robertas
post
Post #1





Grupa: Zarejestrowani
Postów: 2
Pomógł: 0
Dołączył: 25.01.2011

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


mam skrypt:

  1. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
  2. <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="pl" lang="pl">
  3. <head>
  4. <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  5. <title>Przykładowy dokument</title>
  6.  
  7. <style type="text/css">
  8. #abc{
  9. background: red;
  10. height: 300px;
  11. }
  12. </style>
  13. <script type="text/javascript">
  14.  
  15. var c = 0;
  16.  
  17. document.addEventListener("DOMContentLoaded", function(){
  18. showtime = setInterval("animate()", 2);
  19. }, false);
  20.  
  21. function animate(){
  22. var abc = document.getElementById("abc");
  23. var h = abc.offsetHeight;
  24.  
  25. if(c == 700){
  26. clearInterval(showtime);
  27. }
  28.  
  29. h++;
  30. c++;
  31. abc.style.height = h + "px";
  32. }
  33.  
  34. </script>
  35. </head>
  36. <body>
  37. <div id="abc">
  38. Lorem ipsum dol sir amdet
  39.  
  40. </div>
  41. </body>
  42. </html>


objąłem ten skrypt function i dodałem ONclick dla jej wywołania

  1. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
  2. <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="pl" lang="pl">
  3. <head>
  4. <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  5. <title>Przykładowy dokument</title>
  6.  
  7. <style type="text/css">
  8. #abc{
  9. background: red;
  10. height: 300px;
  11. }
  12. </style>
  13. <script type="text/javascript">
  14. function zmien()
  15. {
  16. var c = 0;
  17.  
  18. document.addEventListener("DOMContentLoaded", function(){
  19. showtime = setInterval("animate()", 2);
  20. }, false);
  21.  
  22. function animate(){
  23. var abc = document.getElementById("abc");
  24. var h = abc.offsetHeight;
  25.  
  26. if(c == 700){
  27. clearInterval(showtime);
  28. }
  29.  
  30. h++;
  31. c++;
  32. abc.style.height = h + "px";
  33. }
  34. }
  35. </script>
  36. </head>
  37. <body>
  38. <div id="abc">
  39. Lorem ipsum dol sir amdet
  40. <p onclick="zmien();">Kliknij aby rozwinac</p>
  41. </div>
  42. </body>
  43. </html>


niestety wtedy skrypt nie działa. Proszę o pomoc, siedzę 2 dni i nic nie przychodzi mi do głowy dlaczego w ten sposób nie mogę włączać tej funkcji
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: 21.08.2025 - 05:56