How to get document height and width without using jquery

后端 未结 10 1759
有刺的猬
有刺的猬 2020-11-28 05:26

How to get document height and width in pure javascript i.e without using jquery.
I know about $(document).height() and $(document).width(), bu

10条回答
  •  北荒
    北荒 (楼主)
    2020-11-28 06:00

    This is a cross-browser solution:

    var w = window.innerWidth || document.documentElement.clientWidth || document.body.clientWidth;
    var h = window.innerHeight || document.documentElement.clientHeight || document.body.clientHeight;
    

提交回复
热议问题