Showing results for 
Search instead for 
Did you mean: 

V3491, JavaScript, window.screen object properties width, height, availWidth, and availHeight stopped returning valid values

 I had updated to Intel XDK V3491 and found that the JavaScript window.screen object properties width, height, availWidth, and availHeight stopped returning valid values. No matter the type of cell phone that I choose in the simulator, the width is set to 1366 and height is set to 728. I created a new project to test with and find that no matter what I set access to for the build it will not allow canvas to display on the new project but previous existing project will allow canvas to display. I had opened the new index.html in firefox and found that it would display. I am left contemplating what has changed with the security, access, privileges, associated with both the old and new projects. Could the change in the window.screen object properties be associated with a lack of security privilege in the new version. It now returns these default values. Anyone have any insight, so I don't spend a lot of time tinkering around trying to figure out what has changed? Is this a bug?

Tags (2)
0 Kudos
2 Replies

James -- The results you see in the Debug tab or in a built app will be unchanged, since they depend on the target device. The Simulate tab does have some issues with the window.screen object, it is not setting those values properly, instead, it is showing what your laptop screen values are, which is the proper behavior of the browser implementation for those values (which is what the Simulate tab is, it's a browser pretending to be a device).

You can use the window.innerWidth and window.innerHeight when in the Simulate tab (you can detect the Simulate tab by detecting the presence of window._cordovaSimulate to make the code conditional). See this example screenshot taken from the "hello cordova" sample and the data shown for the device I'm "simulating" in the associated control panel, from the Simulate tab:

Screen Shot 2016-08-15 at 9.13.29 PM.png

Screen Shot 2016-08-15 at 9.15.24 PM.png


I had upgraded to 3491. I couldn't even see the device information in the simulator tab as you show it. I had also found that I couldn't build ANYTHING. I had ended up completely uninstalling Intel XDK using a professional grade uninstaller and then reinstalling it from scratch. The development environment now works a LOT and I mean a LOT better. The uninstall doesn't do anything to the project folders.