1

I was using jQuery $(window)height() to get the height of view-port. This works in all browsers expect safari browser in iPhone 6. It don't give correct height of view-port. I also tried window.innerHeight, but results are same. Any help?

Nafees Anwar
  • 6,324
  • 2
  • 23
  • 42

2 Answers2

0

I will refer you to this post. There is a hacky fix, but it boils down to a bug in Safari mobile (that might also apply to Safari desktop)

Mobile Safari $(window).height() URL bar discrepancy

Community
  • 1
  • 1
Korgrue
  • 3,430
  • 1
  • 13
  • 20
0

I fought a lot with this issue. Safari have a lot of troubles getting the height of an element but I found a javascript method that return the correct height of a specific element.

Here I give you the link and the support confirmation. Actually I used that in a project where I was needing to control an animation depending of an element height.

I hope that it could help someone in my same situation.

https://developer.mozilla.org/en-US/docs/Web/API/Element/getBoundingClientRect

Use the getBoundingClientRect and access to the height attribute like this:

element.getBoundingClientRect().height