Cordova 无法在phonegap(android)中获取窗口高度和宽度

Cordova 无法在phonegap(android)中获取窗口高度和宽度,cordova,Cordova,我使用$(window).width()和$(window).height()获得android设备中webview的屏幕大小。但有时返回值为0。我不知道为什么。请帮我解决这个问题。对不起我的英语:(使用window.innerHeight和window.innerWidth代替。使用window.innerHeight和window.innerWidth。对我来说,这个功能在Android和iOS上运行得非常好 function SetElementHeight(){ screenHeight

我使用$(window).width()和$(window).height()获得android设备中webview的屏幕大小。但有时返回值为0。我不知道为什么。请帮我解决这个问题。对不起我的英语:(

使用
window.innerHeight
window.innerWidth
代替。

使用
window.innerHeight
window.innerWidth

对我来说,这个功能在Android和iOS上运行得非常好

function SetElementHeight(){
screenHeight=$('.ui-mobile').outerHeight(true);
screenWidth=$('.ui-mobile').outerWidth(true);
//console.log("outerHeight= "+ screenHeight);
//console.log("outerWidth= "+ screenWidth);

}
$(window).bind('orientationchange resize', function(event,ui){
 SetElementHeight();
});`

对我来说,这个功能在Android和iOS上运行得非常好

function SetElementHeight(){
screenHeight=$('.ui-mobile').outerHeight(true);
screenWidth=$('.ui-mobile').outerWidth(true);
//console.log("outerHeight= "+ screenHeight);
//console.log("outerWidth= "+ screenWidth);

}
$(window).bind('orientationchange resize', function(event,ui){
 SetElementHeight();
});`