Joined January 2016
·

Marvin Herbold

Phoenix, Arizona
·
·

Posted to Scrollable iframe on mobile Safari over 1 year ago

It will jump to the top any time the iframe content changes. The only workaround that I can find is to explicitly set the height of the iframe to the height of the contents. Something like this (using jQuery).

$('iframe').load(function() {
var self = this;
var oldHeight = 0;
function resizeiframe(eventObject) {
var newHeight = $(self.contentWindow.document).height();
if (newHeight !== oldHeight) {
oldHeight = newHeight;
$(self).css("height", newHeight);
}
}
resizeiframe();
$(self.contentWindow).resize(resizeiframe);
});

Achievements
1 Karma
0 Total ProTip Views