Note that there are some explanatory texts on larger screens.

plurals
  1. POplay images in javascript
    primarykey
    data
    text
    <p>I want to make the image animation using javascript with some controllable functionality, such as play, pause and stop, the following is so far I've tried:</p> <pre><code>&lt;html&gt; &lt;head&gt; &lt;title&gt;Image Player&lt;/title&gt; &lt;script type="text/javascript" language="javascript"&gt; window.onload=function () { var rotator=document.getElementById("slideshow_content"); var images=rotator.getElementsByTagName("img"); for (var i=1; i&lt;images.length; i++) { images[i].style.display="none"; } var counter=1; setInterval(function () { for (var i=0; i&lt;images.length; i++) { images[i].style.display="none"; } images[counter].style.display="block"; counter++; if (counter==images.length) { counter=0; } }, 3000); function playimage() { player.play(); } function pauseimage() { player.pause(); } function stopimage() { player.pause(); player.currentTime=0; } }; &lt;/script&gt; &lt;/head&gt; &lt;body&gt; &lt;div id="slideshow"&gt; &lt;div id="slideshow_content" width="200px" height="200px" style="padding-top: 10px; padding-bottom: 10px;"&gt; &lt;img alt="" src="a.jpg" /&gt; &lt;img alt="" src="b.jpg" /&gt; &lt;img alt="" src="c.jpg" /&gt; &lt;img alt="" src="d.jpg" /&gt; &lt;img alt="" src="e.jpg" /&gt; &lt;img alt="" src="f.jpg" /&gt; &lt;/div&gt; &lt;button onclick="playimage()"&gt; Play&lt;/button&gt;&lt;br /&gt; &lt;button onclick="pauseimage()"&gt; Pause&lt;/button&gt;&lt;br /&gt; &lt;button onclick="stopimage()"&gt; Stop&lt;/button&gt;&lt;br /&gt; &lt;/div&gt; &lt;/body&gt; &lt;/html&gt; </code></pre> <p>But it doesn't work as expected, when I click on <code>start</code> button it doesn't not show me any image ..</p> <p>How can I make it work, as when I click on the start button and the images could be played; when I click on stop and it could stop .. ? </p> <p>What I'm doing wrong and where is the problem?</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.
 

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