title: trying to write cross-browser event disabling js function. what is wrong?
body: <p>I'm trying to write my own function to block events. </p>
  
  <p>here is what i have</p>
  
  <pre><code>function disableEvent (element, event, useCapture) {
  function preventer (event) {
      event = event || window.event;
      event.preventDefault() ? event.preventDefault() : (event.returnValue = false);        
      event.stopPropagation() ? event.stopPropagation() : (event.cancelBubble = true);        
  }    
  if (typeof useCapture == 'undefined') useCapture = false;
      if (element.addEventListener)
          element.addEventListener(event.toLowerCase().substr(2), preventer, useCapture)
      else if (element.attachEvent) {
          var result = element.attachEvent(event,preventer);
          return result;
      }
      else {
          alert("Try to change or update your browser")
      }                        
  </code></pre>
  
  <p>}</p>
  
  <p>But it does not work on IE browser. It shows me an error on 4th line. Appreciate your help with this task. Best regards, Ahmed.</p>