我已经可以用.height和screen.availHeight报告不同的值。这是我的代码:
canvas.height = document.height || document.body.clientHeight;
canvas.width = document.width || document.body.clientWidth;
当我与核对时
alert("canvas.width = " + canvas.width +
"/n canvas.height = " + canvas.height +
"/n screen.availHeight = " + screen.availHeight);
我得到:
canvas.width = 1904 which seems correct;
canvas.height = 191 which is way out of order;
screen.availHeight = 1040 which seems correct.
我是错过了什么还是出了什么问题?
此处
canvas.height = document.height || document.body.clientHeight;
canvas.width = document.width || document.body.clientWidth;
您将文档设置为浏览器大小http://www.w3schools.com/js/js_window.asp
在的情况下
screen.availHeight
availHeight属性返回用户屏幕的高度(以像素为单位),减去Windows任务栏等界面功能。
http://www.w3schools.com/jsref/prop_screen_availheight.asp
您可以使用Math.max(window.innerHeight, document.body.clientHeight)