sheshazam Posted March 18, 2008 Share Posted March 18, 2008 http://www.struttersball.comClick on the Jack and Jill Dance Contest Graphic and my pop up will appear. I hope to add some javascript code to disable scrolling of the main page until they close the pop up box.You can see all my code in the source.Something like: document.body.style.overflow="hidden" ???ThanksShesha Link to comment Share on other sites More sharing options...
justsomeguy Posted March 18, 2008 Share Posted March 18, 2008 Yeah, overflow hidden would work I would imagine, on either the body or the container div. Link to comment Share on other sites More sharing options...
sheshazam Posted March 18, 2008 Author Share Posted March 18, 2008 Yeah, overflow hidden would work I would imagine, on either the body or the container div.Any exact code examples? I'm quite a hack and can't actually seem to write it in a way that actually works.Shesha Link to comment Share on other sites More sharing options...
Jesdisciple Posted March 18, 2008 Share Posted March 18, 2008 EDIT: Woops, post conflict. Link to comment Share on other sites More sharing options...
jeffman Posted March 18, 2008 Share Posted March 18, 2008 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 More sharing options...
sheshazam Posted March 19, 2008 Author Share Posted March 19, 2008 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 More sharing options...
justsomeguy Posted March 19, 2008 Share Posted March 19, 2008 What does it do in IE7? You should probably use "auto" instead of "visible" for the second one. Link to comment Share on other sites More sharing options...
Jesdisciple Posted March 19, 2008 Share Posted March 19, 2008 And I think your users would appreciate it if you would remember the scrollbar's position and reset it when scrolling is re-enabled. Link to comment Share on other sites More sharing options...
sheshazam Posted March 19, 2008 Author Share Posted March 19, 2008 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 More sharing options...
Jesdisciple Posted March 19, 2008 Share Posted March 19, 2008 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 More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.