2 Replies - 4016 Views - Last Post: 20 December 2012 - 06:42 PM

#1 The Architect 2.0  Icon User is offline

  • D.I.C Regular

Reputation: 37
  • View blog
  • Posts: 351
  • Joined: 22-May 08

[IE9] Can't Disable Drag-and-Drop

Posted 17 December 2012 - 06:16 PM

I've encountered a bug where if I press 'ctrl+a' and then try to drag the scrollbar caret on an overflowed div, it won't scroll and will just display a stop sign.

I had a similiar bug for Firefox and disabling drag-and-drop by returning false for mousedown/move/up events corrected it. 'Return false' and 'preventDefault' don't not seem to be affecting IE9 at all. Am I just passing the event object incorrectly? or is disabling drag-and-drop just not the solution for IE9?


$("#container").mousedown(function(event) {
    event.preventDefault();
});



Is This A Good Question/Topic? 0
  • +

Replies To: [IE9] Can't Disable Drag-and-Drop

#2 BetaWar  Icon User is offline

  • #include "soul.h"
  • member icon

Reputation: 1138
  • View blog
  • Posts: 7,105
  • Joined: 07-September 06

Re: [IE9] Can't Disable Drag-and-Drop

Posted 18 December 2012 - 04:15 PM

event.preventDefault isn't in all versions of IE (In fact, I don't believe that it is in IE9). That said, attempting to use it will return a javascript error.

When using functionality which isn't available in all browsers you should make sure to wrap it in an if statement:
$("#container").mousedown(function(e){
  e = e || window.event; // IE doesn't always send the event to the function.
  if(e.preventDefault){
    e.preventDefault();
  }
  if(e.returnValue !== undefined){ // This should exist in IE
    e.returnValue = false;
  }
  return false; // and older browser should pay attention to a callback return value
});


That should work better for you.
Was This Post Helpful? 0
  • +
  • -

#3 The Architect 2.0  Icon User is offline

  • D.I.C Regular

Reputation: 37
  • View blog
  • Posts: 351
  • Joined: 22-May 08

Re: [IE9] Can't Disable Drag-and-Drop

Posted 20 December 2012 - 06:42 PM

Ah yes, I'm just testing the problem in IE9 specifically, so I didn't include any compatibility/error-handling code.

thanks for the help, but it still doesn't solve my issue. Have you been able to replicate my problem?

it seems that firefox is willing to drag-and-drop any type of node, and disabling dragging on a div fixes the problem. However, it seems like IE is smart enough to NOT drag a div. Instead, the problem is that it scrollbar is included in part of the ctrl+a selection. As a result, it registers the click-drag as a drag-and-drop action, rather than a 'move scroll caret' action.

any thoughts?
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1