问题
After launching app with "deviceready" event, my Phonegap app on Android returns false screen.width (window.innerWidth is the same) values on ZTE Blade (native 800px). I get width values like 320, 533 or 787 px, sometimes different values within one app instance (launch) when asking multiple times...
I have android:screenOrientation="landscape" in my AndroidManifest.xml. Using Phonegap/Cordova 1.8.1 in Eclipse (Indigo).
Some sample values of screen.width:
in index.html
- before document.addEventListener+"deviceready": 320
- just after "deviceready": 320
then redirect three times (change window.location to different HTML file) because of 2 splash-screens and finally land to main.html. I include my .js code in every file just for debugging, and get 3 console.logs:
- 320
- 787
- 787
Very strange...
回答1:
There's a comprehensive article (+ comparison tables of different values) that you should read: http://tripleodeon.com/2011/12/first-understand-your-screen/
Hope this helps with your issue.
来源:https://stackoverflow.com/questions/11524669/javascriptphonegapandroid-screen-width-returns-bad-almost-random-values