When you scroll down or up in any web site the Address bar show/hide. I wish identify when the bar is hidden or visible.
Example:
if (chromeBarIsHidden()) {
console.log('a');
} else {
console.log('b');
}
When you scroll down or up in any web site the Address bar show/hide. I wish identify when the bar is hidden or visible.
Example:
if (chromeBarIsHidden()) {
console.log('a');
} else {
console.log('b');
}
There is no native way to do this in any browser. However, using the dimensions and window resize events, there have been solutions developed. See this Stack Overflow answer. However, unless absolutely necessary, I would not recommend this for the following reasons:
window.onresize event to not accurately represent the changewindow.onresize EventThe window.onresize event will fire whenever the browser's window size changes. This can be used to resize and change the layout of the page through JavaScript with different window sizes. To use this, see the example below.
window.onresize = function() {
// Do something on resize
}
window.innerHeight PropertyThe window.innerHeight property returns the view height of the viewport. This can be used to determine if layout arrangements will need to change based on height.
var windowHeight = window.innerHeight;
A better alternative to changing things depending on the viewport size, which changes when the address bar hides itself. See this article by w3schools.