#1250 new
Nick Wing

document.viewport.getHeight() off by 60 in iPhone

Reported by Nick Wing | May 18th, 2011 @ 01:43 AM

I didn't see a ticket for this yet, apologies if I missed it.

When I call document.viewport.getHeight() in iPhone and the address bar is scrolled up to where it's hidden from the user, I get the wrong height. I get the height as if the address bar were still fully visible. Since the address bar is (currently) 60 pixels tall in iPhone Safari, the value is too small by 60.

For now I have:

function getViewportHeight() {
  var vph = document.viewport.getHeight();
  return (window.innerHeight - 60 == vph ? window.innerHeight : vph); 
}

This is awfully fragile but I'm at a loss for a better way.

Comments and changes to this ticket

Please Sign in or create a free account to add a new ticket.

With your very own profile, you can contribute to projects, track your activity, watch tickets, receive and update tickets through your email and much more.

New-ticket Create new ticket

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile ยป

The Prototype JavaScript library.

Shared Ticket Bins

People watching this ticket

Pages