Return the media type the link element is intended for:
var x = document.getElementById("myLink").media;
Click the button to return the media type the link element is intended for.
<!DOCTYPE html> <html> <head> <link id="myLink" rel="stylesheet" type="text/css" media="screen" href="style.css"> </head>/*from www .java2 s . c o m*/ <body> <h1>I am formatted with a linked style sheet</h1> <button onclick="myFunction()">Test</button> <p id="demo"></p> <script> function myFunction() { var x = document.getElementById("myLink").media; document.getElementById("demo").innerHTML = x; } </script> </body> </html>
The media
property sets or gets the media type for the link element.
The style might be different for computers and mobile devices.
The media
property accepts and returns a String type value.
Value | Description |
---|---|
all | all devices. Default |
aural | speech synthesizers |
braille | Braille tactile feedback devices |
embossed | paged Braille printers |
handheld | handheld devices |
printed pages and print preview | |
projection | projectors or transparencies |
screen | color computer screens |
speech | speech synthesizers |
tty | teletype devices |
tv | TV-type devices |
The media
property return a String representing a comma-separated list of media types.