Struggling to prevent body scrolling when a modal pop-up appears? I've tried setting the body overflow to hidden when opening the modal and resetting it when closing, which worked fine on desktop browsers. However, mobile devices like iPod/iPhone posed a challenge. To address this, I included
-webkit-overflow-scrolling: touch;
But even this solution didn't work on iPad. Here's my code:
function toggleMenu() {
if (!toggle) {
$("body").css("overflow", "hidden");
}else{
$("body").css("overflow", "");
}
toggle = !toggle;
Despite exploring various solutions on Stack Overflow and experimenting with position fixed, nothing seems to resolve the issue specifically on iPod. Any help or suggestions would be greatly appreciated. Thank you.