vendredi 3 octobre 2014

is this a good way to detect a mobile browser?


Vote count:

-1




I'm taking advantage that the css text-size-adjust is only used on mobile devices. I came out with a very simple way of detecting a mobile browser. 1) this is the body's css: text-size-adjust:200%; -o-text-size-adjust:200%; -ms-text-size-adjust:200%; -moz-text-size-adjust:200%; -webkit-text-size-adjust:200%; 2) I have a span which has a text with a font size of 22px. on the body onload event I check the offsetHeight of the span. on PCs and laptops the offsetHeight is 29 or 30(it depends on the browser - ie vs chrome). on my mobile windows phone(8.1) the offsetHeight is 59. 3) to be sure its a mobile device I check if the offsetHeight is bigger than 45(I take 14 pixels as a safety factor in case some mobile devices will report less).


What do you think? is most mobile devices support text-size-adjust? is it supported only on mobile phones or also on tablets?



asked 40 secs ago







is this a good way to detect a mobile browser?

Aucun commentaire:

Enregistrer un commentaire