tags:

views:

32

answers:

2

I am applying css style to "body" and to a div which id is "overlay" like:

body
{
    margin:0;
    background:#FEFEFE url(../Images/gradientHeader1.png);
    background-repeat:repeat-x;
}

overLay
{
    background-color:#666666;
    height:1000px;
    left:0;
    opacity:0.5;
    position:absolute;
    margin-top:0;
    width:100%;
    z-index:1003;
}

"overLay" div is inside noscript tag which renders in the browser only when javascript is disabled in the browser.My requirement is that I have to set "overflow:hidden" in the body when "overLay" div get rendered.Can I set overflow property of the body from #overLay?or any other way?

A: 

You need to do it the other way around Set the body to what it needs to be when scripting is off and change it with javascript

mplungjan
+2  A: 

Yes you can do this without scripting:

<noscript>
    <div id="overLay">whatever</div>
    <style type="text/css">
        body {
            overflow: hidden !important;
        }
    </style>
</noscript>

(You also need a # in your CSS rule: #overLay { ... })

nickf
thanks for ur valuable advice.It works fine.But still my need is not compleatly fulfilled.When I use overflow:hidden scrollbar disappears but still key press down or page down works.I do not want the page to scroll down.Can u help me????
ANP
perhaps set the body height to a value?
nickf