PxPlus User Forum

Main Board => Discussions => iNomads => Topic started by: HendersonS on August 31, 2021, 09:41:13 PM

Title: Screen Size
Post by: HendersonS 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.
Title: Re: Screen Size
Post by: Mike King 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.
Title: Re: Screen Size
Post by: Mike King 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 "/".
Title: Re: Screen Size
Post by: HendersonS on September 01, 2021, 06:36:52 PM
Thanks for reply, I did a test with that code and returns an <err>.
Title: Re: Screen Size
Post by: Mike King 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

Title: Re: Screen Size
Post by: HendersonS 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.
Title: Re: Screen Size
Post by: Mike King 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")

Title: Re: Screen Size
Post by: HendersonS 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.