Leff Leff - 1 month ago 6
Javascript Question

Enabling and disabling scrolling on pages

I have two pages and on one page I need to have disabled scrolling and on the other page enabled, but when I try to do that with jQuery the whole screen shakes and it is almost impossible to scroll.

This is how I did it in the script:

$(document).ready(function () {
if (window.location.pathname = '/all') {
$('body').css('overflow-y', 'auto');
} else {
$('body').css('overflow-y', 'hidden');
}
});


Is there an other way which would work to do the same thing?

Answer

I think the problem is with the single equals sign in if statement.

Comments