Window.innerheight Ie8 Alternative
Solution 1:
You might want to try:
document.documentElement.clientHeight;
Or can use jQuery's .height()
method:
$(window).height();
Solution 2:
I made a simple shim for IE8 and others:
window.innerWidth
window.innerHeight
window.scrollX
window.scrollY
document.width
document.height
559 bytes
(function(d,b){var c=b.documentElement;var a=b.body;var e=function(g,h,f){if(typeof g[h]==="undefined"){Object.defineProperty(g,h,{get:f})}};e(d,"innerWidth",function(){return c.clientWidth});e(d,"innerHeight",function(){return c.clientHeight});e(d,"scrollX",function(){return d.pageXOffset||c.scrollLeft});e(d,"scrollY",function(){return d.pageYOffset||c.scrollTop});e(b,"width",function(){returnMath.max(a.scrollWidth,c.scrollWidth,a.offsetWidth,c.offsetWidth,a.clientWidth,c.clientWidth)});e(b,"height",function(){returnMath.max(a.scrollHeight,c.scrollHeight,a.offsetHeight,c.offsetHeight,a.clientHeight,c.clientHeight)});return e}(window,document));
For updates, take a look at this gist: yckart/9128d824c7bdbab2832e
(function (window, document) {
var html = document.documentElement;
var body = document.body;
var define = function (object, property, getter) {
if (typeof object[property] === 'undefined') {
Object.defineProperty(object, property, { get: getter });
}
};
define(window, 'innerWidth', function () { return html.clientWidth });
define(window, 'innerHeight', function () { return html.clientHeight });
define(window, 'scrollX', function () { returnwindow.pageXOffset || html.scrollLeft });
define(window, 'scrollY', function () { returnwindow.pageYOffset || html.scrollTop });
define(document, 'width', function () { returnMath.max(body.scrollWidth, html.scrollWidth, body.offsetWidth, html.offsetWidth, body.clientWidth, html.clientWidth) });
define(document, 'height', function () { returnMath.max(body.scrollHeight, html.scrollHeight, body.offsetHeight, html.offsetHeight, body.clientHeight, html.clientHeight) });
return define;
}(window, document));
Solution 3:
Use following in your document.ready
and define innerHeight
explicitly.
window.innerHeight = window.innerHeight || document.documentElement.clientHeight
Solution 4:
Javascript method to get full window height..:
window.outerHeight;
Javascript methods to get full document height..:
document.body.clientHeight;
or
document.body.offsetHeight;
Javascript methods to get visible document area height..:
this is height of window without bars.
window.innerHeight;
jQuery methods to get visible document area height and window without bars area height too..:
$(window).height();
or
$(window).outerHeight();
jQuery methods to get full document height..:
$(document).height();
or
$(document).outerHeight();
that's all, I hope will help you :)
Solution 5:
I searched on because n o n e of the here posted functions seemed to work, i always got the windowviewheight not the documents full height...
this works in all browsers I've tested...also iexplore 8:
var D = document;
var myHeight = Math.max(
D.body.scrollHeight, D.documentElement.scrollHeight,
D.body.offsetHeight, D.documentElement.offsetHeight,
D.body.clientHeight, D.documentElement.clientHeight
);
alert(myHeight);
Post a Comment for "Window.innerheight Ie8 Alternative"