获取浏览器宽度,自适应屏幕

方法如下:
var myWidth = document.getElementById("#myChart");

var temp = myWidth.style.width=window.innerWidth+'px';
alert(temp);

其他高度获取:

alert($(window).height()); //浏览器当前窗口可视区域高度
alert($(document).height()); //浏览器当前窗口文档的高度
alert($(document.body).height());//浏览器当前窗口文档body的高度
alert($(document.body).outerHeight(true));//浏览器当前窗口文档body的总高度 包括border padding margin

posted @ 2019-08-05 16:00  小刺猬的大宝贝  阅读(700)  评论(0编辑  收藏  举报