Latest web development tutorials

HTML DOM Link media properties

Link Object Reference Link Objects

Definition and Usage

media property sets or returns the device to display the document.

For the style information, the target media is very important. Style mobile devices and desktop computers may be different.

grammar

Setting media properties:

linkObject.media="device"

Returns media properties:

linkObject.media

devicemay have the following values:

value description
screen For non-paged computer screens.
tty Media (such as typewriters, terminals or other devices with limited display capabilities) for the grid of monospaced characters.
tv TV type of device for.
projection For the projector.
handheld For handheld devices.
print Print preview mode for pages and documents.
braille Method for Braille tactile feedback devices.
aural For speech synthesis.
all For all equipment or devices.


Browser Support

Internet ExplorerFirefoxOperaGoogle ChromeSafari

All major browsers support media properties


Examples

Examples

The following examples use the link element to get media types:

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>本教程(w3big.com)</title>
<link id="link1" rel="stylesheet" type="text/css" media="screen" href="style1.css">
<script>
function displayResult(){
    var x=document.getElementById("link1").media;
    alert(x);
}
</script>
</head>
<body>

<button type="button" onclick="displayResult()">显示链接元素的媒介类型</button>

</body>
</html>

try it"


Link Object Reference Link Objects