MediaListNN 6 IE n/a DOM 2  

  

The MediaList object is an abstract representation in the W3C DOM of a collection of string names for media specified for a particular styleSheet object. The media property of a styleSheet object returns a value that is a MediaList object (IE 6 for Windows incorrectly returns a string value). Media types (such as print, screen, aural, and so on) are specified for the style sheet either via the media attribute of a link element or an @media rule in a style element. As of Version 6 browsers, media support beyond print and screen types (and the default all type) is rather limited, so the details of this object are not yet important.

 
Object-Specific Properties
 
lengthmediaText
 
Object-Specific Methods
 
appendMedium( )deleteMedium( )item( )
 
Object-Specific Event Handler Properties

None.

lengthNN 6 IE n/a DOM 2  

Read-only  

Returns the number of items in the collection.

 
Example
 
var howMany = document.styleSheets[0].media.length;
 
Value

Integer.

mediaTextNN 6 IE n/a DOM 2  

Read-only  

Returns the entire string of comma-delimited media names.

 
Example
 
var allMedia = document.styleSheets[0].media.mediaText;
 
Value

String.

appendMedium( ), deleteMedium( )NN 7 IE n/a DOM 2  

appendMedium("mediumType") deleteMedium("mediumType")

  

Adds or removes a medium type from the list. In Netscape 6.2, the methods are incorrectly named append( ) and delete( ).

 
Parameters
 
  • String of recognized media type (e.g., print, screen).
 
Returned Value

None.

item( )NN 6 IE n/a DOM 2  

item(index)

  

Returns one media name string from the collection corresponding to the item matching the index value in source code order.

 
Parameters
 
index

A zero-based integer corresponding to the specified item in source code order.

 
Returned Value

String.