在移动设备上获取窗口高度(jQuery Mobile)

时间:2014-07-11 22:34:12

标签: jquery-mobile

如何在移动设备上获得窗口高度? $(window).height()在桌面设备上运行良好,但只要我从Chrome开发工具模拟移动设备,就会报告窗口高度为1739px。这是为什么?

http://jsfiddle.net/frank_o/ebkeq/3/embedded/result/

$(document).on("pagecontainershow", function() {

  // https://github.com/jquery/jquery-mobile/issues/6306  
  alert($(window).height());
});

1 个答案:

答案 0 :(得分:0)

请在此处查看有关窗口对象的文档:http://www.w3schools.com/jsref/obj_window.asp

尝试

window.innerHeight

window.outerHeight

对于jQuery:

$(window).innerHeight()

http://api.jquery.com/innerHeight/