Document.width
已過時: This feature is obsolete. Although it may still work in some browsers, its use is discouraged since it could be removed at any time. Try to avoid using it.
注意: 從 Gecko 6.0 開始, document.width 將不再被支援。取而代之的是
document.body.clientWidth 。請參照:
element.clientWidth
(en-US).
傳回目前文件中,<body>
(en-US) 元素的寬度有多少像素。
Internet Explorer 不支援!
語法
pixels = document.width;
範例
function init() {
alert("文件的寬度是 " + document.width + " 像素。");
}
其他替代
document.body.clientWidth /* <body> 的寬度 */ document.documentElement.clientWidth /* <html> 的寬度 */ window.innerWidth /* 視窗的寬度 */
規範於
HTML5