[英]Set all <canvas>'s in the html document to the document's width and height?
[英]Getting the document's width and height
我很好奇我将如何获得文档的宽度,看起来可以使用document.body.offsetWidth
获得窗口的宽度,但是我尝试的其他一切都与document.body.offsetWidth
和我的像素不同需要更大的文档宽度,并且在调整窗口大小时不会改变。
function getSize()
{
var w=window,d=document,e=d.documentElement,g=d.getElementsByTagName('body')[0];
var x=w.innerWidth||e.clientWidth||g.clientWidth;
var y=w.innerHeight||e.clientHeight||g.clientHeight;
return {width:x, height:y}
}
var size=getSize();
console.log(size.width+" "+size.height);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.