Note that there are some explanatory texts on larger screens.

plurals
  1. POIE6/7 And ClassName (JS/HTML)
    primarykey
    data
    text
    <p>I am trying to change the class of an element using javascript. So far I'm doing :</p> <pre><code>var link = document.getElementById("play_link"); link.className = "play_button"; </code></pre> <p><strong><em>edit</strong>: here is the actual code that replace the classname</em></p> <p>In the HTML :</p> <pre><code>&lt;a href="#play_link_&lt;%=i%&gt;" id="play_link_&lt;%=i%&gt;"onclick="changeCurrentTo(&lt;%=i%&gt;);return false;" class="play_button"&gt;&lt;/a&gt; </code></pre> <p>In the Javascript function changeCurrentTo(id){ activatePlayButton(current_track); current_track = id; inactivatePlayButton(current_track); }</p> <pre><code>function inactivatePlayButton(id){ document.getElementById("recording_"+id).style.backgroundColor="#F7F2D1"; var link = document.getElementById("play_link_"+id); link.className="stop_button"; link.onclick = function(){stopPlaying();return false;}; } function activatePlayButton(id){ document.getElementById("recording_"+id).style.backgroundColor=""; var link = document.getElementById("play_link_"+id); link.className = "play_button"; var temp = id; link.onclick = function(){changeCurrentTo(temp);return false;}; } </code></pre> <p>with </p> <pre><code>.play_button{ background:url(/images/small_play_button.png) no-repeat; width:25px; height:24px; display:block; } </code></pre> <p>the old class is</p> <pre><code>.stop_button{ background:url(/images/small_stop_button.png) no-repeat; width:25px; height:24px; display:block; } </code></pre> <p>The context is a music player. When you click the play button (triangle) it turns into a stop button (square) and replace the function that is called.</p> <p>The problem is that the class get changed, but in IE6 and 7 the new background (here /images/small_play_button.png) does not display right away. Sometime it doesn't even display at all. Sometime it doesn't display but if I shake the mouse a bit then it displays.</p> <p>It works perfectly in FF, Chrome, Opera and Safari, so it's an IE bug. I know it's hard to tell right away from only these information, but if I could get some pointers and directions that would be helpful. </p> <p>Thanks-</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload