Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.javascript > #33877

Re: detect a phone

Newsgroups comp.lang.javascript
Subject Re: detect a phone
From "Evertjan." <exxjxw.hannivoort@inter.nl.net>
References <WoqdnVwVzJe7ozzEnZ2dnUU7-YvNnZ2d@westnet.com.au>
Date 2017-08-26 11:44 +0200
Message-ID <XnsA7DD77833343Feejj99@194.109.6.166> (permalink)

Show all headers | View raw


Andrew Poulos <ap_prog@hotmail.com> wrote on 26 Aug 2017 in 
comp.lang.javascript:

> I've got a situation where it would be beneficial to know if the js is 
> running on a phone and I thought "instead of parsing navigator.userAgent 
> why not just check for the window screen size?"
> 
> Currently no phone's viewport is larger than 600,

What would be your definition of "phone"?

Tablets can house SIM-cards, 
I can make a phone-call with my desktop,
with my elder "phones" I can only call via VOIP.

> in both width and 
> height, so for the time being would something like
> 
> var isPhone = (window.screen.width < 600 || window.screen.height < 600) 
> && ("ontouchstart" in window);
> 
> be a "safe" way test?

Well, 
unless stretching the definition of "safe", 
and perhaps in fear of unplanned of childNodes, 
I still would advice additional preventative action.

> "safe" way

<https://www.instacart.com/safeway/condoms> 


-- 
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)

Back to comp.lang.javascript | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

detect a phone Andrew Poulos <ap_prog@hotmail.com> - 2017-08-26 19:23 +1000
  Re: detect a phone "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2017-08-26 11:44 +0200
    Re: detect a phone Andrew Poulos <ap_prog@hotmail.com> - 2017-08-27 00:09 +1000
      Re: detect a phone "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2017-08-26 20:02 +0200
  Re: detect a phone Richard Maher <maher_rjSPAMLESS@hotmail.com> - 2017-08-26 20:42 +0800
  Re: detect a phone "Michael Haufe (TNO)" <tno@thenewobjective.com> - 2017-08-26 09:40 -0700
    Re: detect a phone Andrew Poulos <ap_prog@hotmail.com> - 2017-08-27 08:48 +1000
      Re: detect a phone "Michael Haufe (TNO)" <tno@thenewobjective.com> - 2017-08-26 16:31 -0700
      Re: detect a phone Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2017-08-27 03:35 +0200
  Re: detect a phone JJ <jj4public@vfemail.net> - 2017-08-27 00:03 +0700
    Re: detect a phone Andrew Poulos <ap_prog@hotmail.com> - 2017-08-27 08:21 +1000
      Re: detect a phone Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2017-08-27 04:00 +0200
        Re: detect a phone Andrew Poulos <ap_prog@hotmail.com> - 2017-08-27 18:13 +1000
          Re: detect a phone Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2017-08-27 15:15 +0200
    Re: detect a phone Mark Lloyd <not@mail.invalid> - 2017-08-27 11:30 -0500
  Re: detect a phone Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2017-08-27 03:33 +0200

csiph-web