Sanjoy Roy

[MCM, MCP, SCJP] – Senior PHP Programmer

How to hide window scrollbar for IE, FF and Google Chrome

It is easy if you add the attribute scrollbars=no inside the‘s window attributes. But what if you wish to hide them when the popup window is already open. Thank you CSS! Yes, it is possible by using Javascript and accessing the window style’s property overflow. However, there is a cross-browser issue. Both IE and Firefox/Google Chrome have different codes that make this work. You can place both their codes in the same page and/or Javascript function. If the browser does not understand the property, it will ignore it anyway so there is no need to do a browser check to execute the code specific to that certain browser.
The code below does the trick: = 'hidden'; // firefox, chrome
document.body.scroll = "no"; // ie only

Just in case you wish to disable either just the horizontal or vertical scrollbar, this code works for non IE browsers = 'hidden'; // horizontal scrollbar will be hidden = 'hidden'; // vertical scrollbar will be hidden

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: