V
V
vasIvas2015-01-31 20:08:48
JavaScript
vasIvas, 2015-01-31 20:08:48

How to find out the real size of the browser window in js in order to draw canvas without scrolls?

If you set the padding to zero, as in the code below -

<style>
  * {padding: 0; margin: 0;}
</style>

var viewPort = {
  width: window.innerWidth,
  height: window.window.innerHeight
};

var canvas = document.createElement('canvas');
canvas.width = viewPort.width;
canvas.height = viewPort.height;
document.body.appendChild(canvas);

And then draw a canvas with dimensions, as in the code above, then vertical and horizontal scrolls appear. How to avoid it? How to find out the dimensions so that there are no indents and scrolls?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
R
Rikcon, 2015-01-31
@Rikcon

Try somehow using the new vh and vw units.
Unless, of course, you need old browsers.

S
Sergei Nalomenko, 2015-01-31
@nalomenko

This question has been raised on stackoverflow - - here

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question