Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> [JavaScript][HTML] Większe zdjęcie i jego znikanie
pjamalia
post 21.04.2011, 06:03:32
Post #1





Grupa: Zarejestrowani
Postów: 77
Pomógł: 0
Dołączył: 1.11.2009

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


Witam

Oto mój HTML

  1. <img src="fota.jpg" width="255" height="255" onclick="ShowImage('a','fota.jpg');" onmouseout="HideImage('a');"/>


skrypt JS jest następujący:

  1. var check = 0;
  2. var div = null;
  3. function ShowImage(divName,path)
  4. {
  5. if(check == 0)
  6. {
  7. div = document.getElementById(divName);
  8. if( document.getElementById )
  9. {
  10. div.id=path;
  11. div.style.backgroundColor = 'yellow';
  12. div.style.color = 'yellow';
  13. div.style.position = 'absolute';
  14. div.style.pixelLeft= 300;
  15. div.style.pixelTop= 300;
  16. div.style.pixelWidth= 100;
  17. div.style.pixelHeight= 100;
  18. image = document.createElement('img');
  19. image.src=path;
  20. div.appendChild(image);
  21. div.style.visibility = 'visible';
  22. check = 1;
  23. body = document.getElementById(div.id);
  24. body.appendChild(div);
  25. }
  26. else if(document.all)
  27. {
  28. div.id=path;
  29. div.style.backgroundColor = 'yellow';
  30. div.style.color = 'yellow';
  31. div.style.position = 'absolute';
  32. div.style.pixelLeft= 100;
  33. div.style.pixelTop= 100;
  34. div.style.pixelWidth= 10;
  35. div.style.pixelHeight= 10;
  36. image = document.createElement('img');
  37. image.src=path;
  38. div.appendChild(image);
  39. div.style.visibility = 'visible';
  40. check = 1;
  41. body = document.getElementById(div.id);
  42. body.appendChild(div);
  43. }
  44. }
  45. else
  46. {
  47. HideImage(divName);
  48. check = 0;
  49. }
  50. }
  51. function HideImage(divName)
  52. {
  53. //if(check == 1)
  54. //{
  55. //div = document.getElementById(divName);
  56. div.style.visibility = "hidden";
  57. check = 0;
  58. div = " ";
  59. //}
  60. }
  61.  


Nie wiem dlaczego jak ponownie próbuje kliknąć na zdjęcie to wywala mi błąd:
"Div nie jest pusty lub nie jest obiektem wiersz 14" oraz "wymagany jest obiekt wiersz 60"

Nie mogę sobie z tym poradzić.
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 Wersja Lo-Fi Aktualny czas: 14.08.2025 - 06:06