NetTalk Central

Author Topic: Condition small screen device  (Read 3513 times)

Poul Jensen

  • Full Member
  • ***
  • Posts: 189
    • View Profile
    • Email
Condition small screen device
« on: February 24, 2019, 04:12:08 AM »
Other web tools have the possibility of reading the users screen and decide whether it is a small screen (ie. smartphone) or a large screen (tablet or PC).

Then certain elements could be shown or not shown.

Is this possible with NT 11 ?

Cheers
/Poul 

Jane

  • Sr. Member
  • ****
  • Posts: 354
  • Expert on nothing with opinions on everything.
    • View Profile
    • Email
Re: Condition small screen device
« Reply #1 on: February 24, 2019, 10:55:46 AM »
Bruce has illustrated this sort of things several times in the NetTalk webinars using CSS @media queries to determine what to show/hide based on browser size, whether the page is being sent to a printer, etc.

This is better than pure "screen size" because it also allows the web page to adjust if the browser window is resized (rather than full screen).

Look through the webinar show notes for episodes.

Jane

peterH

  • Sr. Member
  • ****
  • Posts: 413
    • View Profile
Re: Condition small screen device
« Reply #2 on: February 24, 2019, 01:28:45 PM »
Jane,

That was also my first thought and I'm using @media queries all over the place.

But I think Poul does have a point here. Sometimes it would be nice knowing if the user is on a phone for example in which case you might want to serve a completely different page rather than 'crippling the page' by using display: none; in your css.

In earlier versions of NT we had IsMobile() as a convenient way of getting at least an approximation of the user's screen size.

Peter

Bruce

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 11186
    • View Profile
Re: Condition small screen device
« Reply #3 on: February 24, 2019, 10:49:31 PM »
If you look at your log you'll see the device reports it's screen-size after the first page requests. This is stored in session values.

>> Sometimes it would be nice knowing if the user is on a phone for example in which case you might want to serve a completely different page rather than 'crippling the page' by using display: none; in your css.

This is _completely_ the wrong approach. You are thinking like 2010 and not 2019. Media Queries are by a country mile the best way of adapting to small screens.

Cheers
Bruce


Poul Jensen

  • Full Member
  • ***
  • Posts: 189
    • View Profile
    • Email
Re: Condition small screen device
« Reply #4 on: February 24, 2019, 10:57:47 PM »
Thanks Jane & Peter,

Like Peter points out, I was looking for the IsMobile() solution, like in H5 where we can query the Broker like this:  Broker.Http.GetIsMobileBrowser()

That would be really helpfull.

@Bruce:  sorry I have to disagree.  There are situations where you have complex browses and where the smartphone users refuses to turn the phone.  In this case you unfortunately need to have two browses and show one or the other depending on the device.

Cheers
/Poul



Bruce

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 11186
    • View Profile
Re: Condition small screen device
« Reply #5 on: February 25, 2019, 07:05:36 AM »
Hi Poul,

>> @Bruce:  sorry I have to disagree.

as I pointed out the screen resolution is in the session queue, if you have that feature (performance tab) turned on.
Also p_web.Agent contains some idea of what the browser is using. You can also inspect p_web._UserAgent if you want to interrogate the UserAgent header.

It's clearly do'able - it's just a really bad idea.

cheers
Bruce