簡體   English   中英

screen.width返回錯誤的大小javascript android

[英]screen.width return wrong size javascript android

我正在編寫1個應用程序使用phonegap。

我使用screen.width.height來獲取屏幕的寬度和高度。

但是當我測試時,返回錯誤的值。 這是我測試過的一些設備和模擬器:

Samsung galaxy mini 2.3.4 (240x320): return random in (240x301) and (320x401)

Panasonic 102p 2.3.5 (540x960): return random in (0x0) and (320x622) and (540x922)

在模擬器移動和表運行android 4.0.1中完美工作

HTC ONE X android 4.1.1 (720x1280): work perfect

經過一些測試,我認為這是錯誤的,因為android 2。

我試過了:

screen.width (height)

screen.availWidth (height)

window.innerWidth (height)

$(window).width() (height)

<uses-sdk android:minSdkVersion="3" android:targetSdkVersion="8" />

我使用下一個代碼,效果很好。

var windowWidth = $(window).width();
var windowHeight = $(window).height();

<uses-sdk android:minSdkVersion="5" android:targetSdkVersion="10" />

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM