[RESOLVED]Wrapping CSS inside javascript

I need to check for user’s browser for a screen width test


function getBrowser()


if (navigator.appName == ‘Microsoft Internet Explorer’)


document.getElementById("main").style = ‘overflow-y: hidden’;



<body onload="getBrowser">
<div id="main" style="width:1260px;">


…I want IExlorer browsers to not show a horizontal scroll bar, whereas the Chrome & mozillas are fine. What may I be missing ( I could also check for browser version with 

var re = new RegExp("MSIE ([0-9]{1,}[.0-9]{0,})");
if (re.exec(ua) != null)
rv = parseFloat( RegExp.$1 );

but just need to really check for Internet Explorer in general



If problem only with IE, then i don’t think, calling overflow on other browsers
create issue in them. so apply it in general.
also, for horizontal scrollbar u have to use overflow-x not -y.

use below js code it should work:

if (navigator.appName == 'Microsoft Internet Explorer')
    document.getElementById("main").style.overflowX = 'hidden';

Leave a Reply