HTML5 new features-Audio video, drag-and-drop

Source: Internet
Author: User

1. Audio

<audio controls>
<source src= "Aaa.ogg" type= "Audio/ogg" >
<source src= "Bbb.mp3" type= "Audio/mpeg" >
Your browser does not support the audio element.
</audio>

Insert prompt text for <audio> elements that the browser does not support between <audio> and </audio>.

The <audio> element allows multiple <source> elements to be used. <source> elements can link different audio files, the browser will use the first supported audio file

2. Video

<video width= "height=" controls>
<source src= "Movie.mp4" type= "Video/mp4" >
<source src= "Movie.ogg" type= "Video/ogg" >
Your browser does not support the video tag.
</video>

The <video> element element also provides the width and Height properties to control the size of the video. If you set the height and width, the required video space is retained when the page loads. If you do not set these properties and the browser does not know the size of the video, the browser will not be able to load a specific space, the page will vary depending on the size of the original video.

3. Drag and Drop

var box1,box2,img
Window.onload = function () {
Box1 = document.getElementById ("Box1");
Box2 = document.getElementById ("Box2");
Box2.ondragstart = function (e) {
Drag (e);
}
Box2.ondragover = function (e) {
DragOver (e);
}
Box2.ondrop = function (e) {
OnDrop (e);
}
img = document.getElementById ("img");
Img.draggable = "false";
}
function drag (EV) {
Ev.dataTransfer.setData ("IMG", IMG);
}
function DragOver (EV) {
Ev.preventdefault ();
}
function OnDrop (EV) {
Ev.preventdefault ();
var imgg = ev.dataTransfer.getData ("img");
Ev.target.appendChild (IMG);
}

To set the element to be drag and drop:

Specifies what happens when an element is dragged-ondragstart and SetData ()

The Datatransfer.setdata () method sets the data type and value of the dragged data

Where to place dragged data-ondragover

By default, data/elements cannot be placed in other elements. If you need to set allow placement, we must block the default handling of elements.

This is done by calling the Event.preventdefault () method of the OnDragOver event:

Event. Preventdefault ()

Place dragged data-ondrop

The dragged data is obtained by means of the Datatransfer.getdata ("Text") method. The method returns any data that is set to the same type in the SetData () method.

Appends the dragged element to the placement element (the target element)

HTML5 new features-Audio video, drag-and-drop

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.