Name
MediaList — a style sheet’s list of media types
Availability
DOM Level 2 StyleSheets
Properties
-
readonly unsigned long length
The length of the array; the number of media types in the list.
-
String mediaText
A comma-separated text representation of the complete media list. Setting this property may throw a DOMException with a
code
ofSYNTAX_ERR
if the new value contains a syntax err, or acode
ofNO_MODIFICATION_ALLOWED_EXCEPTION
if the media list is read-only.
Methods
-
appendMedium( )
Adds a new media type to the end of the list.
-
deleteMedium( )
Removes the specified media type from the list.
-
item( )
Returns the media type at the specified position in the list, or
null
if the index is invalid. In JavaScript, you can also treat the MediaList object as an array and index it using normal square-bracket array notation instead of calling this method.
Description
This interface represents a list or array of media types for a style
sheet. length
specifies the number of elements in
the list, and item( )
allows a specific media type
to be retrieved by position. appendMedium( )
and
deleteMedium( )
allow entries to be appended to
and deleted from the list. JavaScript allows a MediaList object to be
treated as an array, and you can use square-bracket notation instead
of calling item( )
.
The HTML 4 standard defines the following media types (they are
case-sensitive, and must be written in lowercase letters):
screen
, tty
,
tv
, projection
,
handheld
, print
,
braile
, aural
, and
all
. The screen ...
Get JavaScript: The Definitive Guide, Fourth Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.