How to get document height and width without using jquery

后端 未结 10 1747
有刺的猬
有刺的猬 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:01

    How to find out the document width and height very easily?

    in HTML

    in javascript

         var c=document.querySelector('#hidden_placer');
    
         var r=c.getBoundingClientRect();
         r.right=document width
         r.bottom=document height`
    

    You may update this on every window resize event, if needed.

提交回复
热议问题