Source typeProperty

Source 对象参考手册Source Object

Examples

Return the MIME type of the media resource:

var x = document.getElementById("mySource").type;

xThe output result is:

audio/mpeg

Try it Yourself »

Definition and Usage

The type property sets or returns the value of the type attribute of the <source> element.

The type attribute specifies the MIME type of the media resource.

Note:The <source> element is new in HTML5.


Browser Support

Internet ExplorerFirefoxOperaGoogle ChromeSafari

All major browsers support the type property.


Syntax

Return the type property:

sourceObject.type

Set the type property:

sourceObject.type=MIME_type

Property Values

Value Description
MIME_type Specifies the MIME type of the media resource.

Common MIME types:
Video:
  • video/ogg
  • video/mp4
  • video/webm
Audio:
  • audio/ogg
  • audio/mpeg
See alsoIANA MIME types, for a complete list of standard MIME types.

Technical Details

Return Value: A string, representing the MIME type of the media resource.


Related Articles

HTML Reference Manual:HTML <source> type Attribute


Source 对象参考手册Source Object

Other Extensions