title: JavaScript: Horizontal Scrolling with Mouse Wheel
body: <p>Based off this: <a href="http://reader-download.googlecode.com/svn/trunk/full-page-horizontal-scrolling.html" rel="nofollow">http://reader-download.googlecode.com/svn/trunk/full-page-horizontal-scrolling.html</a> I cannot for the life of me get it to work in IE 10 in either standards or Quirks mode. I have a jsFiddle here but it only scrolls vertical: <a href="http://jsfiddle.net/dwsRC/1/" rel="nofollow">http://jsfiddle.net/dwsRC/1/</a></p>
  
  <p>The scrolling code is 100% the same as the example site. I have tried other scrolling samples but preventDefault won't work. Adding jQuery doesn't help either.</p>
  
  <p>In Visual Studio 2012 I get: </p>
  
  <blockquote>
    <p>JavaScript runtime error: Object doesn't support property or method
    'preventDefault'</p>
  </blockquote>
  
  <p><strong>HTML:</strong></p>
  
  <pre><code>&lt;div id="container"&gt;
      &lt;div class="content c1"&gt;Hello, World!&lt;/div&gt;
      &lt;div class="content c2"&gt;Hello, World!&lt;/div&gt;
      &lt;div class="content c3"&gt;Hello, World!&lt;/div&gt;
      &lt;div class="content c1"&gt;Hello, World!&lt;/div&gt;
      &lt;div class="content c2"&gt;Hello, World!&lt;/div&gt;
      &lt;div class="content c3 last"&gt;Hello, World!&lt;/div&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p><strong>CSS:</strong></p>
  
  <pre><code>#container {
      height: 100%;
      width: 6000px;
      overflow: hidden;
  }
  .content {
      width: 895px;
      height: 675px;
      float:left;
      margin-right:50px;
  }
  .c1 {
      background-color: red;
  }
  .c2 {
      background-color: blue;
  }
  .c3 {
      background-color: green;
  }
  </code></pre>
  
  <p><strong>JS:</strong></p>
  
  <pre><code>(function () {
      function scrollHorizontally(e) {
          e = window.event || e;
          var delta = Math.max(-1, Math.min(1, (e.wheelDelta || -e.detail)));
          document.body.scrollLeft -= (delta * 40); // Multiplied by 40
          e.preventDefault();
      }
      if (window.addEventListener) {
          // IE9, Chrome, Safari, Opera
          window.addEventListener("mousewheel", scrollHorizontally, false);
          // Firefox
          window.addEventListener("DOMMouseScroll", scrollHorizontally, false);
      } else {
          // IE 6/7/8
          window.attachEvent("onmousewheel", scrollHorizontally);
      }
  })();
  </code></pre>