In ie9, window.innerHeight and document.body.clientHeight only works when the content is larger than the document window.
A reliable solution is to use the vw and vh css properties.
css (simple) way:
html, body { width: 100vw; height: 100vh; }
js path:
// make a fitted htmlelement and returns its size. var get_ie_size=function(){ var domtest = document.createElement('div'); domtest.style.display="block"; domtest.style.width="100vw"; domtest.style.height="100vh"; document.body.appendChild(domtest); var size = [domtest.offsetWidth,domtest.offsetHeight]; document.body.removeChild(domtest); return size; };
yorg Jun 22 '15 at 21:35 2015-06-22 21:35
source share