Skip to main content

Bug Tracker

Side navigation

#6724 closed bug (cantfix)

Opened June 25, 2010 03:54PM UTC

Closed February 18, 2013 07:09PM UTC

Last modified April 10, 2014 01:50PM UTC

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:
Blocked by: Blocking:
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"

Attachments (0)
Change History (29)

Changed June 25, 2010 03:56PM UTC by bv comment:1

my current workaround:

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

Changed September 30, 2010 06:37AM UTC by msjol comment:2

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

Changed October 14, 2010 03:22AM UTC by addyosmani comment:3

owner: → bv
priority: → undecided
status: newpending

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?

Changed October 14, 2010 03:24AM UTC by addyosmani comment:4

#6746 is a duplicate of this ticket.

Changed November 11, 2010 11:09PM UTC by trac-o-bot comment:5

status: pendingclosed

Automatically closed due to 14 days of inactivity.

Changed September 07, 2011 08:46PM UTC by anonymous comment:6

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.

Changed September 19, 2011 10:30AM UTC by anonymous comment:7

Replying to [comment:6 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

Changed October 17, 2011 10:50PM UTC by anonymous comment:8

Same here in ios 5

window.innerHeight is correct

Changed November 02, 2011 09:25PM UTC by jay.blanchard@sigmaphinothing.org comment:9

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

Changed November 02, 2011 09:32PM UTC by anonymous comment:10

Replying to [comment:9 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.

Changed January 07, 2012 04:51AM UTC by Richard deCastongrene <richard@acm.org> comment:11

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

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

Changed January 09, 2012 05:51PM UTC by decastongrene comment:12

This happens with jquery 1.7.1. Can it be reopened?

Changed February 22, 2012 01:55PM UTC by anonymous comment:13

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

Changed March 27, 2012 04:01PM UTC by imanol@berein.com comment:14

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

Use window.innerHeight and window.innerWidth instead.

Changed April 23, 2012 09:56PM UTC by rvwoens@gmail.com comment:15

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

use

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

as workaround

Changed April 27, 2012 02:02PM UTC by anonymous comment:16

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

Changed April 29, 2012 06:40PM UTC by jzaefferer comment:17

Is this addressed by #9434?

Changed April 29, 2012 08:08PM UTC by dmethvin comment:18

milestone: 1.4.3
status: closedreopened

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.

Changed May 04, 2012 02:32PM UTC by atirip comment:19

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

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

Changed May 05, 2012 03:41AM UTC by farmdawgnation comment:20

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

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

Changed May 05, 2012 01:14PM UTC by dmethvin comment:21

keywords: iphone mobile safari window heightiphone safari
milestone: → 1.8
priority: undecidedlow
status: reopenedopen

Changed May 16, 2012 06:05PM UTC by Matt Farmer comment:22

resolution: → fixed
status: openclosed

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

Changeset: ca48d490407b198e022b0d0294a7493602155f74

Changed June 12, 2012 04:24AM UTC by anonymous comment:23

this is not fixed.

Changed July 05, 2012 11:56AM UTC by david@insideout.io comment:24

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.

Changed July 05, 2012 01:27PM UTC by dmethvin comment:25

_comment0: See the discussion here: https://github.com/jquery/jquery/commit/ca48d490407b198e022b0d0294a7493602155f74 \ 1341494926124436

Changed February 18, 2013 01:52PM UTC by anonymous comment:26

The problem remains.

Changed February 18, 2013 07:08PM UTC by dmethvin comment:27

milestone: 1.8
resolution: fixed
status: closedreopened

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.

Changed February 18, 2013 07:09PM UTC by dmethvin comment:28

resolution: → cantfix
status: reopenedclosed

Changed April 10, 2014 01:50PM UTC by fpoli comment:29

I think this is the solution for this bug.

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