<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>wheel &#8211; stoimen&#039;s web log</title>
	<atom:link href="/tag/wheel/feed/" rel="self" type="application/rss+xml" />
	<link></link>
	<description>on web development</description>
	<lastBuildDate>Tue, 13 Feb 2018 08:18:15 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>https://wordpress.org/?v=5.0.3</generator>
	<item>
		<title>JavaScript disable mouse wheel</title>
		<link>/2009/07/01/javascript-disable-mouse-wheel/</link>
		<comments>/2009/07/01/javascript-disable-mouse-wheel/#comments</comments>
		<pubDate>Wed, 01 Jul 2009 07:08:14 +0000</pubDate>
		<dc:creator><![CDATA[Stoimen]]></dc:creator>
				<category><![CDATA[javascript]]></category>
		<category><![CDATA[micro tutorial]]></category>
		<category><![CDATA[mouse]]></category>
		<category><![CDATA[wheel]]></category>

		<guid isPermaLink="false">/?p=635</guid>
		<description><![CDATA[Attaching Event Listeners in JavaScript Everybody knows how different is to attach event listeners under different browsers. Under IE is attachEvent(), while under FF is addEventListener()! The compatibility can be checked in the PPK site www.quirksmode.org where the author describes in detail where a given event listener can be registered and how it should be &#8230; <a href="/2009/07/01/javascript-disable-mouse-wheel/" class="more-link">Continue reading <span class="screen-reader-text">JavaScript disable mouse wheel</span> <span class="meta-nav">&#8594;</span></a><div class='yarpp-related-rss'>

Related posts:<ol>
<li><a href="/2009/06/20/openlayers-disable-mouse-wheel-on-zoom/" rel="bookmark" title="OpenLayers disable mouse wheel on zoom">OpenLayers disable mouse wheel on zoom </a></li>
<li><a href="/2009/07/29/cancel-bubbling-on-element-click-with-jquery/" rel="bookmark" title="cancel bubbling on element click with jQuery">cancel bubbling on element click with jQuery </a></li>
<li><a href="/2009/10/08/jquery-the-difference-between-mouseout-and-mouseleave/" rel="bookmark" title="jQuery: the difference between mouseout and mouseleave">jQuery: the difference between mouseout and mouseleave </a></li>
<li><a href="/2010/01/26/prevent-link-default-action-when-mousedown-and-mouseup-fires/" rel="bookmark" title="Prevent link default action when mousedown and mouseup fires!">Prevent link default action when mousedown and mouseup fires! </a></li>
</ol>
</div>
]]></description>
				<content:encoded><![CDATA[<h2>Attaching Event Listeners in JavaScript</h2>
<p>Everybody knows how different is to attach event listeners under different browsers. Under IE is <strong>attachEvent()</strong>, while under FF is <strong>addEventListener()</strong>! The compatibility can be checked in the PPK site <a title="Quirks Mode" href="http://www.quirksmode.org/" target="_blank">www.quirksmode.org</a> where the author describes in detail where a given event listener can be registered and how it should be done.</p>
<h2>Event Bubbling</h2>
<p>Important part of the events in JavaScript is the so called &#8220;<strong>event bubbling</strong>&#8220;. You know, when you click on a given DOM element when bubbling is on the DOM elements containing this specific DOM element receive the event. So when I move the mouse over a DIV element the event <strong>mousemove</strong> is received in every element containing that DIV up to the window object.</p>
<p>In Mozilla it should look like this:</p>
<blockquote>
<pre>element.addEventListener('mousemove', callback, false);</pre>
</blockquote>
<p>Where the third parameter is describing the use of event bubbling, when setup to false, and if it&#8217;s set to true the other type of event handling is used, the so called capturing, which in breaf is the oposite of bubbling and the event is propagated from the top to bottom. The problem under different browsers is that sometimes this <strong>&#8220;mousemove&#8221;</strong> is not enough. In the case of <strong>mousewheel</strong> there are several combinations.</p>
<p>In IE:</p>
<blockquote>
<pre>document.attachEvent('onmousewheel', function(e){
     if (!e) var e = window.event;
     e.returnValue = false;
     e.cancelBubble = true;
     return false;
}, false);</pre>
</blockquote>
<p>In Safari:</p>
<blockquote>
<pre>document.addEventListener('mousewheel', function(e){
    e.stopPropagation();
    e.preventDefault();
    e.cancelBubble = false;
    return false;
}, false);</pre>
</blockquote>
<p>In Opera:</p>
<blockquote>
<pre>document.attachEvent('mousewheel', function(e){
    if (!e) var e = window.event;
    e.returnValue = false;
    e.cancelBubble = true;
    return false;
}, false);</pre>
</blockquote>
<p>In Firefox:</p>
<blockquote>
<pre>document.addEventListener('DOMMouseScroll', function(e){
    e.stopPropagation();
    e.preventDefault();
    e.cancelBubble = false;
    return false;
}, false);</pre>
</blockquote>
<p>Note the differences between all the browsers.</p>
<div class='yarpp-related-rss'>
<p>Related posts:<ol>
<li><a href="/2009/06/20/openlayers-disable-mouse-wheel-on-zoom/" rel="bookmark" title="OpenLayers disable mouse wheel on zoom">OpenLayers disable mouse wheel on zoom </a></li>
<li><a href="/2009/07/29/cancel-bubbling-on-element-click-with-jquery/" rel="bookmark" title="cancel bubbling on element click with jQuery">cancel bubbling on element click with jQuery </a></li>
<li><a href="/2009/10/08/jquery-the-difference-between-mouseout-and-mouseleave/" rel="bookmark" title="jQuery: the difference between mouseout and mouseleave">jQuery: the difference between mouseout and mouseleave </a></li>
<li><a href="/2010/01/26/prevent-link-default-action-when-mousedown-and-mouseup-fires/" rel="bookmark" title="Prevent link default action when mousedown and mouseup fires!">Prevent link default action when mousedown and mouseup fires! </a></li>
</ol></p>
</div>
]]></content:encoded>
			<wfw:commentRss>/2009/07/01/javascript-disable-mouse-wheel/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
	</channel>
</rss>
