HTML - attributes - onpause

revision:


Content

"onpause" attribute : when audio/video is paused syntax some examples


"onpause" attribute : when audio/video is paused

top

The onpause attribute defines a script to be run when the audio/video is paused either by the user or programmatically.

The onpause attribute is part of the event attributes and can be used on the following elements:<audio> and <video>.

The onplay attribute is used to define a script to run when the audio/video has been started or is no longer paused.


syntax

top

<element onpause="script"></element>

script: the script event runs when the onpause attribute is called.


some examples

top

Play and pause the audio file.

codes:
                    <p class="spec">Play and pause the audio file.</p>
                    <audio style="margin-left:3vw;"" id="myAudio" controls onpause="pauseAudio()">                                      
                    <source src="../../pics/horse.wav" type="audio/wav">
                    Your browser does not support the audio element.
                    </audio>
                    <script>
                        function pauseAudio() {
                            alert("The audio file has been paused");
                        }
                    </script> 
                

Play and pause the video.

codes:
                    <p class="spec">Play and pause the video.</p>
                    <video style="margin-left:3vw" id="myVideo" width="320" height="176" controls onpause="pauseVideo()">
                    <source src="../../pics/Wuzhen-20-10_02.mp4" type="video/mp4">
                    Your browser does not support HTML5 video.
                    </video>
                    <script>
                        function pauseVideo() {
                        alert("The video has been paused");
                        }
                    </script>