Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
fix jQuery.offset() in Mobile Safari (iPad, iPhone)
// as of 1.4.2 the mobile safari reports wrong values on offset()
// remove once it's fixed
if ( /webkit.*mobile/i.test(navigator.userAgent)) {
(function($) {
$.fn.offsetOld = $.fn.offset;
$.fn.offset = function() {
var result = this.offsetOld(); -= window.scrollY;
result.left -= window.scrollX;
return result;
Copy link

mataspetrikas commented Jun 9, 2010

related to this bug

Copy link

karlwestin commented Aug 10, 2010

Thanks! Works perfectly :)

Copy link

chumtarou commented Feb 25, 2011

Would love to know how to implement your fix to Jquery Tookit's Tooltips. Once you scroll, the tooltips appear in the wrong location. (

Copy link

jonesmac commented Jul 27, 2017

I think this is still an issue today. I found wrapping it in a timeout solved it which tells me that even if document.ready has safari is still laying things out and getting wrong calculations.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment