简体   繁体   中英

Stop Internet Explorer 8 Page From Scrolling

is it possible? basically i have a 'popup' that appears on a page when a user clicks a button, and i can get the page to stop scrolling in most browsers with:

body.style.overflow = "hidden";

but that doesn't work for IE? I have also tried this as a hack:

body.style.position = "fixed";

that actually works, but it returns the user to the top of the page!

is there a way to do this with only js/css? and not jq?

you could set the positioning to fixed and the overflow to scroll. So if the user does scroll the page the pop up stays and you can still scroll the pop up if the length or width exceeds your set proportions. Style it in CSS:

#popup
{
margin:auto;
width:600px;
height:300px;
background-color:#666;
position:fixed;
overflow:scroll;
}

I'm not sure if this is what you are trying to achieve it'd be much easier if you posted a demo of what you have so far

Use float: left instead of position: fixed or position: absolute . It will work for sure. :)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM