jQuery scrollTop not working inside iframe on Iphone

Viewed 60

This works everywhere, except for iframe on iOS.

the example is as

when you click on a category it should scroll , only I have the problem that it doesn't work on IOS

https://codepen.io/fdemian/full/ZjpXBe

I used

        $('html, body').animate({ scrollTop: offsetTop }, 0);
2 Answers

You have to animate $("body") and not $("html, body") because the mobile ios doesn’t know it

I testesd it again. Seeing other solutions, the following function worked for me:

  • for smartphone (apple, android)
    window.scrollTo(x, y)
  • for pc
    $('html,body').animate({scrollTop: x, scrollLeft: y}, milliseconds)
Related