How Do I Get innerWidth in Internet explorer 8

前端 未结 8 1073
一整个雨季
一整个雨季 2020-12-08 00:06

In all recent browser:

 window.innerWidth // 1920

In Internet explorer 8

 window.innerWidth // undefined

相关标签:
8条回答
  • 2020-12-08 00:51

    for ie8 use

    document.documentElement.clientWidth
    
    0 讨论(0)
  • 2020-12-08 00:53

    The innerWidth is supported by IE9 not IE8, you can do this insteaad:

    var width = window.innerWidth || document.documentElement.clientWidth || document.body.clientWidth;
    

    The above line will get you the width from IE as well as other standard-compliant browsers.


    If you use jQuery, $(window).innerWidth() will give you desired result in all browsers too.

    0 讨论(0)
提交回复
热议问题