javascript - Scroll in-page element only, not the whole page -


Never notice, when you scroll an overflow div or textarea with a mouseover, and you scroll down Does the whole page scroll start?

Can it be stopped?

I have done a quick test of the jQuery scrolls () event handlers, but it appears that there is a fire from a very long time.

If you want to play around, here's the test code.

  & lt; Html & gt; & Lt; Top & gt; & Lt; Script src = "http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js" type = "text / javascript" charset = "UTF-8" & gt; & Lt; / Script & gt; & Lt; Script type = "text / javascript" charset = "UTF-8" & gt; $ (Function () {$ ('# scroller'). Scroll (function () {$ ('# notice'). CSS ('display', 'block'). FadeOut (); return back;})}) & Lt; / Script & gt; & Lt; / Head & gt; & Lt; Body style = "height: 2000px" & gt; & Lt; Div id = "scroller" style = "width: 500px; height: 500px; overflow: scrolling; margin: 50px" & gt; & Lt; Div style = "width: 1000px; height: 1000px; background: #ddd" & gt; & Lt; / Div & gt; & Lt; / Div & gt; & Lt; Div id = "notification" style = "display: none" & gt; Bang & lt; / Div & gt; & Lt; / Body & gt; & Lt; / Html & gt;  

This JS will do this, basically just set the overflow to the body Is hidden when the mouse is more than the Div # scroller, then when you mouse out, set it back to normal.

  $ ("# scroller"). Css ('overflow', 'hidden');}, function () {$ ('body'). CSS ('overflow', 'auto');} ;  

Tested on Safari, Firefox and IE8


Comments

Popular posts from this blog

c# - sqlDecimal to decimal clr stored procedure Unable to cast object of type 'System.Data.SqlTypes.SqlDecimal' to type 'System.IConvertible' -

Calling GetGUIThreadInfo from Outlook VBA -

Obfuscating Python code? -