Jump to content

Using Javascript to Disable Page Scrolling for my CSS Pop Up


sheshazam

Recommended Posts

Something like: document.body.style.overflow="hidden"
I tried exactly this code (literally pasted it) in Firefox 2...12 (MAC) and it worked exactly the way you want it to. Scrollbar just vanishes.
Link to comment
Share on other sites

I tried exactly this code (literally pasted it) in Firefox 2...12 (MAC) and it worked exactly the way you want it to. Scrollbar just vanishes.
Laf! I swear I tried that. Well it worked for me too. Who knew I was so smart and so stupid.This works in Safari 3.1 that came out today and in Firefox 2.... but Not IE 7. Any ideas for IE7? You can see the updated code on the source.
function togglePOP(div_id) {	var el = document.getElementById(div_id);	if ( el.style.display == 'none' ) {		el.style.display = 'block';	document.body.style.overflow="hidden"	}	else {	el.style.display = 'none';	document.body.style.overflow="visible"	}

Link to comment
Share on other sites

Updated to "auto" thank you for that Justsomeguy.Firefox: Works perfectly.Safari: Works almost perfectly. The scroll bar does not return until I click the page or scroll with scroll weel. No importance to me.IE on my Wintendo: Scrollbar vanishes but scrolling with scroll wheel still works on the whole page.IE on Parallels: Scroll bar is always visible and scrolling always works.Current code...

function togglePOP(div_id) {	var el = document.getElementById(div_id);	if ( el.style.display == 'none' ) {		el.style.display = 'block';	document.body.style.overflow="hidden"	}	else {	el.style.display = 'none';	document.body.style.overflow="auto"	}

Link to comment
Share on other sites

Here's a potential lead for IE: http://msdn2.microsoft.com/en-us/library/m...966(VS.85).aspx If you return false from that it might disable scrolling, but you should also anticipate Firefox (although document.body.onscroll didn't work for me in Firefox): http://developer.mozilla.org/en/docs/DOM:element.onscroll (I don't know where Safari's documentation is, but you might also want to check that.)

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...