# Firefox windowWidth and windowHeight return values that are slightly too high

**URL:** https://discourse.processing.org/t/firefox-windowwidth-and-windowheight-return-values-that-are-slightly-too-high/34769
**Category:** p5.js
**Created:** [January 21, 2022, 5:52am UTC](https://discourse.processing.org/t/firefox-windowwidth-and-windowheight-return-values-that-are-slightly-too-high/34769 "2022-01-21T05:52:52Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![mtavictim](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/mtavictim/32/15513_2.png) [@mtavictim](https://discourse.processing.org/u/mtavictim)
#### Post date: [January 21, 2022, 5:52am UTC](https://discourse.processing.org/t/firefox-windowwidth-and-windowheight-return-values-that-are-slightly-too-high/34769/1 "2022-01-21T05:52:53Z")

</div>

I’ve recently gotten back into p5 after a few months. In that time, I’ve switched browsers from Brave (a Chromium derivative, if I remember correctly) to Firefox. When I opened a p5 project from a while ago in Firefox, I noticed that the window was slightly too large. Like, by a factor of maybe 20 pixels?

I’ve done some experiments and determined that this is definitely a Firefox based issue. Here’s a simple sketch I made in Atom:

```auto
function setup() {
  createCanvas(windowWidth, windowHeight);
}

function draw() {
  background(255, 69, 0);
}

```

Here’s how that sketch appears in my default browser, Firefox (note the navigation bars on the bottom and side of the window):

 ![image](https://canada1.discourse-cdn.com/flex036/uploads/processingfoundation1/original/2X/b/b54ea04567d001dbc5dc3fe96367c64f159112d7.png)

However, if I open the same sketch in Edge, the issue is not present (I get an orange screen with no navigation bars on the sides of the window) [I would post an image to prove it, but Discourse doesn’t let new users put multiple images in one post].

I’ve checked, my Firefox settings are not zoomed in.

I checked online, and I found one mention of this kind of issue on stackoverflow:

> <https://stackoverflow.com/questions/28402100/wrong-value-for-window-innerwidth-during-onload-event-in-firefox-for-android>

On the above thread, they explain that (for some reason) Firefox resizes all pages _after_ they’ve been loaded, which renders window.innerWidth (and, I assume by extension, window.innerHeight) incorrect.  
Is there any fix I can make within p5, or do I need to calculate my own windowWidth / windowHeight variables “once the whole document has been loaded and resized,” like they mention in the stackoverflow thread?

---

<div class="post-metadata">

### Author: ![josephh](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/josephh/32/210_2.png) [@josephh](https://discourse.processing.org/u/josephh)
#### Post date: [January 21, 2022, 9:05pm UTC](https://discourse.processing.org/t/firefox-windowwidth-and-windowheight-return-values-that-are-slightly-too-high/34769/2 "2022-01-21T21:05:39Z")

</div>

Hi @mtavictim,

This is correct, I am able to reproduce your issue in Firefox.

With this CSS hack it works thought:

```css
html,
body {
  margin: 0;
  padding: 0;
  overflow: hidden;
}

```

It removes any padding and margin and hide the scroll bars… 😋

---

<div class="post-metadata">

### Author: ![mtavictim](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/mtavictim/32/15513_2.png) [@mtavictim](https://discourse.processing.org/u/mtavictim)
#### Post date: [January 22, 2022, 12:24am UTC](https://discourse.processing.org/t/firefox-windowwidth-and-windowheight-return-values-that-are-slightly-too-high/34769/3 "2022-01-22T00:24:29Z")

</div>

It works! Thank you so much!!
