Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

308
Views
How to find out browser's true width & height (without resizing)

I'm creating a JavaScript canvas game. My logic include whether a sprite has went to the bottom of the browser window (as the canvas is 100% width & 100% height).

Thus, it can be quite confusing if the browsers' height keeps changing, as I'm not sure what's the intended behaviour if a sprite that has already go to the bottom is exposed by resizing the window to a larger height.

I think my options are:

  1. refer the width & height of browser without resizing, OR
  2. When client resize the browser mid game, there should be a "Please resize browser back to the initial size" and a button to do so (as resizing to a specific size can be quite hard)

I think option 2 isn't feasible as it is not supported by Chrome & Opera since its easy to abuse the resize functionality.

For number 1, I haven't find if there is any property that supports this. I tried:

console.log("width ", document.documentElement.clientWidth);
console.log("height ", document.documentElement.clientHeight);

window.onresize = function() {
  console.log("width ", document.documentElement.clientWidth);
  console.log("height ", document.documentElement.clientHeight);
}

I also tried document.innerWidth & innerHeight but it is still not the true browser's width & height. It is the width & height after resizing OR width & height after reduced with chrome dev tool's width & height. Is there any way I can accomplish this?

Thanks

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!