Last Updated: August 26, 2019
·
74.17K
· stffndtz

Scrollable iframe on mobile Safari

In order to make an iframe scrollable on iOs, you have to add the CSS3 property "-webkit-overflow-scrolling:touch" to the parent container.

<div style="overflow:auto;-webkit-overflow-scrolling:touch">
  <iframe src="./yxz" style="width:100%;height:100%">
</div>

12 Responses
Add your response

Thank you! You just spared me a whole morning of groping in the dark! ;-)

over 1 year ago ·

Thank you! works perfectly!

over 1 year ago ·

Worked like a charm! Thanks!

over 1 year ago ·

Yesssssss! This is the simplest, best answer to this problem I've found. Thank you!

over 1 year ago ·

good one
but when i scrolling the page it jump to top page in some point,

it happened to somebody?

over 1 year ago ·

Cool! fine tanks!

over 1 year ago ·

Great! You saved my time! Thanks!

over 1 year ago ·

Awesome! working fine. Thanks!

over 1 year ago ·

I have the same issue for jump back to top when touch the page at some point. Anyone solve this issue? Thanks.

over 1 year ago ·

I don't think this works: http://output.jsbin.com/sesenuziri

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);
});

over 1 year ago ·

Awesome that worked perfectly for iphone!! What would the equivalent be for android?

over 1 year ago ·