i running issues determining type of browser using javascript. current method capture screen width , height , determine type of browser based on pixel sizes.
i figured assume screen width under 768 mobile, under 1024 tablet, , above desktop.
i've started testing on few devices can hands on , results different. instance on android (droid bionic exact though doesn't matter much) returning width of 980 regardless if device in landscape or portrait mode. higher assumed.
currently using document.documentelement.clientwidth determine width have tried other approaches such window.innerwidth well.
i guess trying @ question has been asked many of times , thought had pretty clear answer to. apparently might time refresh on proper browser/device detection. effective way determine actual size of device on?
update: seems if mobile browsers taking upon decide how display application. , in fact are, there way stop it. see answer. fortunately means standard feature detection methods used still best way determine device using.
per dagg nabbit's comment on question:
it seems mobile browsers take upon determine way site displayed. typically means taking desktop version of website , zooming out fit contents on screen. 90% of internet necessary otherwise mobile browsing experience horrifying. responsive websites no because in cases have specific elements must altered depending on resolution of device site being viewed on. how stop browsers doing this?
by using viewport meta tag. standard tag looks this:
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
but there lot of different ways can customize suit needs. reference https://developer.mozilla.org/en-us/docs/mobile/viewport_meta_tag
Comments
Post a Comment