Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> [js] setAttribute nie działa w IE
dyktek
post
Post #1





Grupa: Zarejestrowani
Postów: 240
Pomógł: 0
Dołączył: 18.01.2004
Skąd: rzeszów / kraków

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


Napisałem ostatnio kodzik w js, takie ostatnio popularne gwiazdki do głosowania, wynik działania poza IE widać tutaj problem polega właśnie w IE, nie wiem czemu ten kod nie działa pod tym badziewiem, wydaje mi się że problem tkwi w setAttribute, wie ktoś może jak to ominąć?


  1. <head>
  2. <script type="text/javascript">
  3.  
  4. var g_clear = 'g_white.gif';
  5. var g_fill = 'g_green.gif';
  6. var ile = 5;
  7.  
  8. var x = 29;
  9. var y = 29;
  10.  
  11. function $( id ){
  12. return document.getElementById( id );
  13. }
  14.  
  15. function generuj(){
  16. var iden = $( 'ocena' );
  17.  
  18. for( i = 0; i < ile; i++ ){
  19.  
  20. docBody = $( 'ocena' );
  21. element = document.createElement("img");
  22. element.id = i ;
  23. docBody.appendChild(element);
  24.  
  25. incre = i + 1;
  26.  
  27. element.setAttribute("src", g_clear);
  28. element.setAttribute("width", x);
  29. element.setAttribute("height", y);
  30.  
  31. element.setAttribute("onMouseOver", "zmien('"+incre+"');");
  32.  
  33.  
  34. $('ocena').setAttribute("onMouseOut", "czysc();");
  35.  
  36. }
  37.  
  38. }
  39.  
  40. function zmien(nr){
  41. for(i = 0; i < nr; i++)
  42. $(i).setAttribute("src", g_fill);
  43. }
  44.  
  45. function czysc(){
  46. for( i = 0; i < ile; i++ )
  47. $(i).setAttribute("src", g_clear);
  48. }
  49.  
  50. </script>
  51. </head>
  52. <body onload="generuj();">
  53.  
  54. <div id="ocena"></div>
  55.  
  56. </body>
  57. </html>


właściwie to już sobie poradziłem

trzeba było zrobić taki cuś:

  1. if(navigator.appName == 'Microsoft Internet Explorer'){
  2. element.setAttribute("onmouseover", function zaz(){ zmien(this.name); });
  3. element.setAttribute("onmouseout", function dez(){ czysc(); });
  4. } else {
  5. element.setAttribute("onMouseOver", "zmien('"+incre+"');");
  6. $('ocena').setAttribute("onMouseOut", "czysc();");
  7. }
Go to the top of the page
+Quote Post

Posty w temacie


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: 15.10.2025 - 09:22