javascript - Maintain background scroll when modal opens -



javascript - Maintain background scroll when modal opens -

i had looked through many other questions on , other sites. having same issue neither of solutions working me. mutual solution saw remove # href attribute of a tag modal opens on click of div , other having different cases, neither of them suited situation.

what happens when scroll downwards , click on div open modal, modal opens successfully. before that, having issue when opened modal, scrollbar added , per reply of previous question, said this:

body.modal-open { overflow: hidden !important; }

i did , worked when open up, background scrolls top. know that's happening because of position: fixed property. might need specify top attribute maintain scroll position everytime, top offset alter no constant top value top property.

i looked out finding out page's scroll offset , found utilize window.pageyoffset figure out how much user has scrolled background. tried log value of pageyoffset console doing this:

window.onscroll = function() { console.log(window.pageyoffset); }

but everytime scrolled it, continuously logged 0 console.

i have no thought how prepare issue. please help. thanks.

fiddle.

change

body.modal-open {overflow: hidden!important;}

to

body.modal-open { overflow: auto; }

you need alter anchors <a href="#"> <a href="javascript:void(0)"> or proper anchor not top of page.

javascript jquery html css twitter-bootstrap

Comments

Popular posts from this blog

php - Android app custom user registration and login with cookie using facebook sdk -

django - Access session in user model .save() -

php - .htaccess Multiple Rewrite Rules / Prioritizing -