1、精简版
function ScreenSize() {
let width = 0;
let height = 0;
if (window.innerWidth) {
width = window.innerWidth;
height = window.innerHeight;
} else {
width = document.documentElement.clientWidth;
height = document.documentElement.clientHeight;
}
return {
width: width,
height: height,
};
}
2、完整版
function ScreenSize() {
let width = 0;
let height = 0;
if (window.innerWidth) {
width = window.innerWidth;
height = window.innerHeight;
} else {
if (document.compatMode === "BackCompat") {
width = document.body.clientWidth;
height = document.body.clientHeight;
} else {
width = document.documentElem