Javascript examples for DOM HTML Element:Link
The media property sets or gets the media type for the link element.
Set the media property with the following Values
Value | Description |
---|---|
all | all devices. This is 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 |
A String, representing a comma-separated list of media types
The following code shows how 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="styles.css"> </head>/* w w w. j a v a 2s. c om*/ <body> <h1>I am formatted with a linked style sheet</h1> <button onclick="myFunction()">Test</button> <p id="demo"></p> <script> function myFunction() { var v = document.getElementById("myLink").media; document.getElementById("demo").innerHTML = v; } </script> </body> </html>