PxPlus User Forum

Twitter Twitter Twitter

Author Topic: Screen Size  (Read 1759 times)

HendersonS

  • Gold Member
  • ****
  • Posts: 58
    • View Profile
Screen Size
« on: August 31, 2021, 09:41:13 PM »
Hi everyone!  using inomads is there any way to calculate the screen size of the device that is being used?, in nomads we usually use MSE to calculate the dimensions but apparently it doesn't work in inomads.

Mike King

  • Diamond Member
  • *****
  • Posts: 3810
  • Mike King
    • View Profile
    • BBSysco Consulting
Re: Screen Size
« Reply #1 on: September 01, 2021, 08:44:54 AM »
When using iNomads, and in fact when developing web applications, screen size is dynamic since on desktops it depends on the size of the browser window and on tablets it depends on the screen orientation.

That being said you can use the js_eval method to pass a JavaScript request for the device size .. but whatever value you get can change at any time.
Mike King
President - BBSysco Consulting
eMail: mike.king@bbsysco.com

Mike King

  • Diamond Member
  • *****
  • Posts: 3810
  • Mike King
    • View Profile
    • BBSysco Consulting
Re: Screen Size
« Reply #2 on: September 01, 2021, 10:31:09 AM »
To save you from looking up the JavaScript the following would give you the window size in pixels:

    %inomads'js_eval$("window.innerWidth +'/' + window.innerHeight")

It will return a string consisting of the width and height separated by a "/".
Mike King
President - BBSysco Consulting
eMail: mike.king@bbsysco.com

HendersonS

  • Gold Member
  • ****
  • Posts: 58
    • View Profile
Re: Screen Size
« Reply #3 on: September 01, 2021, 06:36:52 PM »
Thanks for reply, I did a test with that code and returns an <err>.
« Last Edit: September 01, 2021, 08:04:06 PM by HendersonS »

Mike King

  • Diamond Member
  • *****
  • Posts: 3810
  • Mike King
    • View Profile
    • BBSysco Consulting
Re: Screen Size
« Reply #4 on: September 01, 2021, 10:41:58 PM »
Make sure you have the case right.

I tested it on my system first and it ran fine using chrome

Mike King
President - BBSysco Consulting
eMail: mike.king@bbsysco.com

HendersonS

  • Gold Member
  • ****
  • Posts: 58
    • View Profile
Re: Screen Size
« Reply #5 on: September 02, 2021, 02:18:50 PM »
Sorry, I might be missing something, I just copy and paste the code you posted(see attached),and return that. i using chrome.

Mike King

  • Diamond Member
  • *****
  • Posts: 3810
  • Mike King
    • View Profile
    • BBSysco Consulting
Re: Screen Size
« Reply #6 on: September 03, 2021, 07:48:01 AM »
No idea why you get an error -- the function js_eval$ passes the parameter to the browser to execute.

Try accessing the fields individually as in:

%inomads'js_eval$("window.innerWidth")

and

%inomads'js_eval$("window.innerHeight")

Mike King
President - BBSysco Consulting
eMail: mike.king@bbsysco.com

HendersonS

  • Gold Member
  • ****
  • Posts: 58
    • View Profile
Re: Screen Size
« Reply #7 on: September 07, 2021, 08:35:17 PM »
Thanks for reply mike,
 
Could already find out why the js_val method was returning an error, the  problem was that I wanted to know the size of the mobile device screen to load one program or another and inadvertently I was executing the code before the inomads.js was loaded (I guess it is the interface that executes that method).

i did the test with inomads.js loaded and it worked fine.