add-to-homescreen icon indicating copy to clipboard operation
add-to-homescreen copied to clipboard

isStandalone and status of DOM loading

Open benjiwheeler opened this issue 10 years ago • 0 comments

just finished debugging to figure out why i couldn't get a callout to appear on my Moto X Android 4.4.4 running current Chrome.

turns out problem was that isStandalone was being evaluated to true inside addtohomescreen.js, erroneously. the culprit was document.documentElement.clientHeight . When i inspected this value after DOM load, it was 511 (about what you would expect in-browser with a screen height of 640). A value of 511 would make isStandalone evaluate to false, because it indicates that there is a lot of URL navbar etc taking up vertical real estate.

but when i put an alert right into addtohomescreen.js, i saw that when isStandalone was being set, document.documentElement.clientHeight had a value of 1300 or so! No idea why, but when i threw the entire addtohomescreen.js inside a jQuery $(function() { ... }); then document.documentElement.clientHeight was 511, as it should be, and the callout showed up fine!

is the moral of the story to do like the demos/ examples do and include addtohomescreen.js in the body, not the header? should we put something like window.onload = function() { ... }; around the current contents of addtohomescreen.js? (so as not to require jQuery)

benjiwheeler avatar Feb 05 '15 20:02 benjiwheeler