I want to detect in Javascript if a Smart App banner is currently displayed. I already inspected the DOM but there is no evidence of the banner.
How to detect in javascript if a Smart Banner App is currently displayed?
4.7k views Asked by Marco Marsala At
3
There are 3 answers
2
On
While the Smart App Banner doesn't show up in the DOM, it does decrease the available height of the browser window by 84 pixels ( that's the number I got with IOS7 + iPhone5 ).
I'm going to use this decrease in window.innerHeight to determine if the SmartBanner is displayed.
( I'll need to determine if the user has iPhone4 or iPhone5 )
Mobile Safari does have other bits that affect the window.innerHeight but at most the bottom menu ( share, etc. ) and the larger address bar at the top decrease available height by 69 pixels ( again that's what I got via the Safari Web Inspector ).
This is an old question, but maybe this will be useful to someone. I did this in a following way:
window.matchMedia
to determine device type and orientation with media queries;window.innerHeight
After my experiments I have following experimental window.innerHeight values for different devices with banner shown. You can find them below:
544px
;286px
;475px
;247px
;376px
;148px
;288px
;148px
.Hope this will help someone.