Bug Tracker

Ticket #6724 (closed bug: cantfix)

Opened 4 years ago

Last modified 5 months ago

wrong $(window).height() in mobile safari (iphone)

Reported by: bv Owned by: bv
Priority: low Milestone:
Component: dimensions Version: 1.4.2
Keywords: iphone safari Cc:
Blocking: Blocked by:

Description

using $(window).height() in iphone's mobile safari gives wrong values

user agent:

"Mozilla/5.0 (iPhone; U; CPU iPhone OS 2_2_1 like Mac OS X; de-de) AppleWebKit/525.18.1 (KHTML, like Gecko) Version/3.1.1 Mobile/5H11 Safari/525.20"

Change History

comment:1 Changed 4 years ago by bv

my current workaround:

height = window.innerHeight ? window.innerHeight : $(window).height()

comment:2 Changed 4 years ago by msjol

Same problem here, used the same workaround. Seems to be a problem on iPad as well.

comment:3 Changed 4 years ago by addyosmani

  • Owner set to bv
  • Priority set to undecided
  • Status changed from new to pending

This issue appears to be very similar to what is also being experienced in #6746 with individual elements.

Could you please provide a test case of what you're trying to do here so that we can more accurately evaluate your original ticket?

comment:4 Changed 4 years ago by addyosmani

#6746 is a duplicate of this ticket.

comment:5 Changed 4 years ago by trac-o-bot

  • Status changed from pending to closed

Automatically closed due to 14 days of inactivity.

comment:6 follow-up: ↓ 7 Changed 3 years ago by anonymous

I ran into the exact same problem, I had to explicitly use .innerHeight when iphone. Error did not happen in newest ipad, but happens on iphone still.

comment:7 in reply to: ↑ 6 Changed 3 years ago by anonymous

Replying to anonymous:

I ran into the exact same problem, I had to explicitly use .innerHeight when iphone. Error did not happen in newest ipad, but happens on iphone still.

Same here, issue occurs on iPhone 4 - (FW 4.3.5)

but works fine on iPad 2 - (4.3 (8f191)

Can someone reopen the ticket please? I cannot change the status.

Regards

comment:8 Changed 3 years ago by anonymous

Same here in ios 5

window.innerHeight is correct

comment:9 follow-up: ↓ 10 Changed 3 years ago by jay.blanchard@…

I am finding the same issue, can the ticket be re-opened?

comment:10 in reply to: ↑ 9 Changed 3 years ago by anonymous

Replying to jay.blanchard@…:

I am finding the same issue, can the ticket be re-opened?

Never mind, it is reporting correctly - I zigged before I zagged.

comment:11 Changed 3 years ago by Richard deCastongrene <richard@…>

I was able to duplicate this by first scrolling up to hide the iphone address bar. After that

$(window).height() != window.innerHeight

comment:12 Changed 3 years ago by decastongrene

This happens with jquery 1.7.1. Can it be reopened?

comment:13 Changed 3 years ago by anonymous

This is still happening on the iPhone 4 with the latest version of JQM. The fix stated at the top works still.

comment:14 Changed 2 years ago by imanol@…

Still happening on iPad and iPhone on IOS 5 with jQuery 1.7.1.

Use window.innerHeight and window.innerWidth instead.

comment:15 Changed 2 years ago by rvwoens@…

$(window).height gives screensize on iOS, not innerHeight. tested JQ 1.7.1

use var winheight= window.innerHeight ? window.innerHeight:$(window).height();

as workaround

comment:16 Changed 2 years ago by anonymous

Sounds like $(window).height(); returns screen's height minus address bar (minus Debug Console bar if activated).

comment:17 Changed 2 years ago by jzaefferer

Is this addressed by #9434?

comment:18 Changed 2 years ago by dmethvin

  • Status changed from closed to reopened
  • Milestone 1.4.3 deleted

Doesn't look like it. The recommendation there was for $(window).innerHeight to return $(window).height(), which returns the wrong value according to this ticket.

I'll reopen this with the faith that someone will provide both a test case and a patch. I don't have an iPhone so I can't test it.

comment:19 Changed 2 years ago by atirip

here's the test (this test cannot be presented in jsfiddle).

 http://bkp.ee/atirip/bugs/jh.html

comment:20 Changed 2 years ago by farmdawgnation

Hm. Might be worth noting here that we have an active pull request for this.

 https://github.com/jquery/jquery/pull/764

comment:21 Changed 2 years ago by dmethvin

  • Keywords mobile window height removed
  • Priority changed from undecided to low
  • Status changed from reopened to open
  • Milestone set to 1.8

comment:22 Changed 2 years ago by Matt Farmer

  • Status changed from open to closed
  • Resolution set to fixed

Fix #6724, though the Mobile Safari wound remains. Closes gh-764.

Changeset: ca48d490407b198e022b0d0294a7493602155f74

comment:23 Changed 2 years ago by anonymous

this is not fixed.

comment:24 Changed 2 years ago by david@…

tested with jQuery 1.8b1 and 1.7.2 on iPhone/iOS 5.1

the issue is not fixed. jQuery is reporting the height minus the bar. when the document scrolls and the bar disappears, the height is not recalculated.

comment:25 Changed 2 years ago by dmethvin

Last edited 2 years ago by dmethvin (previous) (diff)

comment:26 Changed 19 months ago by anonymous

The problem remains.

comment:27 Changed 19 months ago by dmethvin

  • Status changed from closed to reopened
  • Resolution fixed deleted
  • Milestone 1.8 deleted

If the discussion in the pull request above wasn't clear enough, we are unable to fix the issue with Safari. I will re-close this as cantfix to make that clear. You should try to convince Apple that this is a problem.

comment:28 Changed 19 months ago by dmethvin

  • Status changed from reopened to closed
  • Resolution set to cantfix

comment:29 Changed 5 months ago by fpoli

I think this is the solution for this bug.

 http://viralpatel.net/blogs/jquery-window-height-incorrect/

Note: See TracTickets for help on using tickets.