1. 程式人生 > >H5頁面彈窗後禁止滾動及禁止滾動釋放

H5頁面彈窗後禁止滾動及禁止滾動釋放

1.禁止頁面滾動

        document.getElementsByTagName('body')[0].setAttribute('style', 'position:fixed; width:100%;')

2.釋放

         document.getElementsByTagName('body')[0].setAttribute('style', 'position:relative;')

可以將這兩行程式碼封裝為兩個函式,隨時使用。