I need to lock the browser scrollbars when I show a div that represent a modal window in Internet Explorer 7 only. Googling I found that I can use document.body.style.overflow='hidden' but this doesn’t work for IE7. I also tried with document.body.scroll='no' which works but only after I mouse over the scrollbar :-S
Does anybody knows a better aproach?
Thansks
To answer your various questions (including that in your other comment), I think you’re using the wrong positioning method.
Try
position:fixed. It’s basically the same asposition:absoluteapart from it’s relative to the absolute viewport. Ie: if the user scrolls, the item stays in the same place on the screen.So with this in mind, you can lay out a
position:fixedoverlay. Within that you can have yourposition:absolute(orfixedagain, if you prefer — it shouldn’t make a difference) modal box.