window.innerHeight ie8 alternative

后端 未结 5 1123
再見小時候
再見小時候 2020-12-08 07:53

I have some calculations that rely on window.innerHeight. But as I have found out this is not available in any IE before IE9. All the other options I have look

5条回答
  •  执笔经年
    2020-12-08 08:34

    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); 
    

提交回复
热议问题