You are here: Reference > JavaScript > client-side > style handling > methods > deleteMedium (mediaList)

deleteMedium method (mediaList)

Browser support:
9
Removes a media type from the mediaList collection.
Note: The mediaList object and its deleteMedium method are supported in Internet Explorer from version 9.
Media types are the target devices for style properties.
Media types can be specified for the @import and media at-rules in CSS, or by the media property for the style and link elements in JavaScript.

Syntax:

object.deleteMedium (mediumType);
You can find the related objects in the Supported by objects section below.

Parameters:

mediumType
String that specifies the type of the media to remove.
One of the following values:
all
Default. For all media.
aural
Speech synthesizers.
braille
Braille tactile feedback devices.
embossed
Paged braille printers.
handheld
Handheld devices.
print
Printed pages and print preview.
projection
Projectors or print to transparencies.
screen
Color computer screens.
speech
Intended for speech synthesizers.
tty
Teletypes.
tv
Television-type devices.

Return value:

This method has no return value.

Example HTML code 1:

This example illustrates the use of the deleteMedium method.
<head>
    <style id="myStyle">
        @media screen, print {
            body {
                font-size: 13px;
                color: #FF0000;
            }
          }
    </style>
    <script type="text/javascript">
        function RemoveScreenMedia () {
            var styleTag = document.getElementById ("myStyle");

                // the style sheet in the style tag
            var sheet = styleTag.sheet ? styleTag.sheet : styleTag.styleSheet;


            if (sheet.cssRules) {   // all browsers, except IE before version 9
                var rule = sheet.cssRules[0];
                var mediaList = rule.media;

                alert ("The media types before removing the screen media type: " + mediaList.mediaText);
                mediaList.deleteMedium ("screen");
                alert ("The media types after removing the screen media type: " + mediaList.mediaText);
            }
            else {  // Internet Explorer before version 9
                    // note: the rules collection does not contain the at-rules
                alert ("Your browser does not support this example!");
            }
        }
    </script>
</head>
<body>
    The color of this text is red on the print preview and on the screen, too. 
    You can remove the screen media with the button below.<br />
    <button onclick="RemoveScreenMedia ();">Remove screen media</button>
</body>
Did you find this example helpful? yes no

Supported by objects:

Related pages:

User Contributed Comments

Post Content

Post Content