I have a (Javascript) tool which dynamically creates a div whenever the user clicks on the screen.
_newDiv = document.createElement('div');
Now, after I’ve created _newDiv
, I want to assign a onmousedown
event to it.
_newDiv.onmousedown = function(event) { onNewDivMouseDown(event); };
This works perfectly in Firefox, but doesn’t work in IE 8. Is there any hack I can use to solve this problem?
Advertisement
Answer
Problem solved!
It turns out that due to the fact that the dynamically created div was made transparent using progid:DXImageTransform, IE didn’t capture the onmousedown event for said div. The problem was solved by inserting
background-image:url(/none)
in the div’s stylesheet. For some reason it works even if a non-existing image is inserted, so I used that.