Skip to content

Instantly share code, notes, and snippets.

@JoshyFrancis
Last active September 18, 2018 08:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save JoshyFrancis/2354a13fadc0e0fa240de83acf836949 to your computer and use it in GitHub Desktop.
Save JoshyFrancis/2354a13fadc0e0fa240de83acf836949 to your computer and use it in GitHub Desktop.
How to find out the document width and height very easily?
in HTML
<span id="hidden_placer" style="position:absolute;right:0;bottom:0;visibility:hidden;"></span>
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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment