0

I want to resize my window browser to the content size and I am using window.resizeTo function (ref) to do this. However I cannot calculate height of browser's address bar. I've tried

window.outerHeight - window.innerHeight

but it also includes the height of browser interface. Is there any way to get the size of address bar in browsers. Take a look at the following picture; I want size of red area or maybe a way to hide it and remove it from the outerHeight calculation

Size of address bar

Reza
  • 3,473
  • 4
  • 35
  • 54
  • Why don't you just use ``innerHeight``? – Sandip Nirmal Sep 12 '19 at 11:31
  • The size of your innerHeight and innerWidth are the exact dimensions of your viewport, no need of other properties or calculations – Mosè Raguzzini Sep 12 '19 at 11:39
  • I don't want to get the size of window. I want to set a custom size to it with `window.resizeTo` function. If I set e.g. 500*500, the inner width and height are less than 500. [window.resizeTo](https://developer.mozilla.org/en-US/docs/Web/API/Window/resizeTo) – Reza Sep 12 '19 at 12:34
  • https://stackoverflow.com/questions/50990006/get-android-chrome-browser-address-bar-height-in-js – Pete Sep 12 '19 at 12:49
  • @Pete Thanks. I saw it before but I couldn't find my answer there :( – Reza Sep 12 '19 at 12:55
  • It would help if you explain what you are trying to do - what you need the height for as this may be an xy problem – Pete Sep 12 '19 at 12:56
  • Let's make it simple. Assume that the body size is 500x500. I want to set the size of my window to 500x500. I tried to use `window.resizeTo` function but it doesn't work. It set the size of whole browser window ( including scroll bars, title bars, etc ) to 500x500 – Reza Sep 12 '19 at 13:00

1 Answers1

1

This is not doable with javascript. You can do a system-dependent hack on your own system, but the moment the browser or system changes, this will be thrown off, because all systems have their own chrome (window decoration) and they are all different.