问题描述
我有一个使用jQuery(窗口).height()的整页幻灯片,它在大多数浏览器上工作正常,但是我在手机上检查了它(Android Browser& Dolphin),幻灯片显示无休止地增长,很好超出视口高度。
这是我的代码:
var height = jQuery(window).height();
jQuery('。slide')。each(function(index,element){
if(height> 600)jQuery(this).height(height);
else jQuery(this )。高度(600);
});
jQuery(window).on('resize orientationChanged',function(){
jQuery('。slide')。each(function(index,element){
if(height> 600)jQuery(this).height(height);
else jQuery(this).height(600);
});
});
任何想法可能导致什么?
所以在这个问题3年后问jquery窗口高度仍然无法在移动设备中工作只需用jquery代替javascript它适用于我。
替换jquery
var bodyh = jQuery(body)。height();
var windowh = jQuery(window).height();
使用javascript
var bodyh = document.body.clientHeight;
var windowh = window.innerHeight;
I have a full page slideshow using jQuery(window).height() and it works fine on most browsers, however I checked it out on my phone (Android Browser & Dolphin) and the slideshow just keeps growing endlessly, well beyond the height of the view-port.This is my code:
var height = jQuery(window).height();
jQuery('.slide').each(function(index, element) {
if(height > 600) jQuery(this).height(height);
else jQuery(this).height(600);
});
jQuery(window).on('resize orientationChanged', function() {
jQuery('.slide').each(function(index, element) {
if(height > 600) jQuery(this).height(height);
else jQuery(this).height(600);
});
});
Any ideas what could be causing it?
Thanks.
so after 3 year of this question asked jquery window height still not working in mobile devices just replace jquery with javascript and it worked for me.
replace jquery
var bodyh = jQuery("body").height();
var windowh = jQuery(window).height();
with javascript
var bodyh = document.body.clientHeight;
var windowh = window.innerHeight;
这篇关于jQuery(window).height()不适用于移动浏览器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!