Anandu Anandu - 4 months ago 13x
jQuery Question

How To Prevent Scrolling Until The Page Loads

I Use This JavaScript until my page loads it shows a simple image.but the problem is the users can scroll the page making the loading animation move up.i want to prevent this.anyone please help is the code i use.Scrolling Is Prevented In Linux(ubuntu) But I am Able To Scroll In Windows


if you do what @joe suggested, and there is no js available, and you dont have another css rule applied later on, then the screen will be unscrollable. better off having after body tag a script that is applied immediately

  $('html, body').css({ 'overflow': 'hidden', 'height': '100%' })
  markup blah blah blah
  $('html, body').removeAttr('style')

and have another script at the bottom just before body tag to remove style attribute.

if you do with css instead of js, just have the style tags in the same place that the script tags are placed