HTML DOM media 属性

定义和用法

The media property sets or returns on what device the document will be displayed.

The destination medium is important for style information. The style might be different for computers and mobile devices.

语法

linkObject.media=device

Device can have one of the following values:

描述
screen For non-paged computer screens
tty For media using a fixed-pitch character grid (like teletypes, terminals, or devices with limited display capabilities)
tv For TV-type devices (low resolution, limited scrollability)
projection For projectors
handheld For handheld devices (small screen, limited bandwidth)
print For paged and for documents viewed on screen in print preview mode
braille For braille tactile feedback devices
aural For speech synthesizers
all For all devices

实例

The following example gets the media type the link element is intended for:

<html>
<head>
<link rel="stylesheet" type="text/css" media="screen"
id="style1" href="try_dom_link.css" />
</head>
<body>

<script type="text/javascript">
x=document.getElementById("style1");
document.write("Intended media type=" + x.media);
</script>

</body>
</html>