HTML - attributes - onw...

revision:


Content

"onwaiting" attribute : whem the video stops for buffering

"onwheel" attribute : when the wheel of a device is rolled up/down



"onwaiting" attribute : whem the video stops for buffering

top

The onwaiting attribute defines a script to run when the video stops because it needs to buffer the next frame. This event can also be used on <audio> elements, but it is mostly used for videos.

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

syntax

<element onwaiting="script"></element>

script: this attribute contains single value script which works when the onwaiting event is called.

some examples

example

codes:

                    <video style="margin-left:3vw;" controls id="videoID" width="400" height="auto">
                        <source src="../pics/Wuzhen-20-10_02.mp4" type="video/mp4">
                    </video>
                    <script>
                        document.getElementById("videoID").addEventListener("waiting", videoFun());
                
                        function videoFun() {
                            alert("start buffering");
                        }
                    </script>
                


"onwheel" attribute : when the wheel of a device is rolled up/down

top

The onwheel attribute fires when the wheel of a pointing device is rolled up or down over an element. The onwheel attribute also fires when the user scrolls or zooms on an element by using a touchpad (like the "mouse" of a laptop).

The onwheel attribute is part of the event attributes and can be used on any HTML element.

syntax

<element onwheel="script"></element>

script: this attribute contains single value script which works when the onwheel event is called.

some examples

example
This example demonstrates how to assign an "onwheel" event event to a DIV element. Roll the mouse wheel over me - either up or down!

A function is triggered when you roll the mouse wheel over div. The function sets the font-size of div to 35 pixels.

HTML codes:

                    <div style="margin-left:3vw;" id="myDIV" onwheel="myFunction()">This example demonstrates how to 
                    assign an "onwheel" event event to a DIV element. Roll the mouse wheel over me - either up 
                    r down!</div>
                    <p class="spec">A function is triggered when you roll the mouse wheel over div. The function sets 
                    the font-size of div to 35 pixels.</p>
                    <script>
                        function myFunction() {
                        document.getElementById("myDIV").style.fontSize = "35px";
                        }
                    </script>
                    <style>
                        #myDIV { border: 1px solid black; }
                    </style>
                

example
This example demonstrates how to assign an "onwheel" event event to a DIV element. Roll the mouse wheel over me - either up or down!

A function is triggered when you roll the mouse wheel over div. The function sets the background to lightgreen.

HTML codes:

                    <div style="margin-left:3vw;" id="myDIV_1" onwheel="myFunction_1()">This example demonstrates how to 
                    assign an "onwheel" event event to a DIV element. Roll the mouse wheel over me - either up 
                    or down!</div>
                    <p class="spec">A function is triggered when you roll the mouse wheel over div. The function sets
                    the background to lightgreen.</p>
                    <script>
                        function myFunction_1() {
                            document.getElementById("myDIV_1").style.background = "lightgreen";
                        }
                    </script>
                    <style>
                        #myDIV_1 { border: 1px solid black; }
                    </style>