Forum Moderators: open
I tried alternatives like
document.getElementsByTagName("body")[0].style.overflow = "auto";
window.document.body.scroll = 'no';
but none of these work in IE, in firefox it disables the scrollbar as i needed but not in IE..is there any solution for this...
thanks - vicky
<html>
<body>
<div style="width:5000px; background-color:red">test</div>
</body>
<script>document.body.style.overflow = "hidden";</script>
</html>
- Maybe you have the overflow property defined also elsewhere, which overwrites this one.
To verify that install (if needed) Firefox with Dom Inspector, then when your page is loaded go to the tools menu -> 'Dom Inspector' or Ctrl-Shift-I. Then select the body tag in the left tree of the Dom Inspector. In the right pane choose in the menu : 'Object - Computed Style' instead of 'Object - Dom Node'. Now you can see below the computed (final) value of the overflow property for the body element.
- or maybe try to add : body {overflow:visible;} so you'll have :
<html>
<style>
body {overflow:visible;}
</style>
<body>
<div style="width:5000px; background-color:red">test</div>
</body>
<script>document.body.style.overflow = "hidden";</script>
</html>
The property overflow in the <style> is needed for IE and the same property overflow is needed in the <script> for Firefox. I don't know exactly why but it works for both IE and Firefox for me.