Setaper
Setaper

Reputation: 171

e.preventDefault() in ie8

I already read this, but i still can't make it work. 'e' just don't have property 'returnValue'. What's wrong?

Html

<img id="vtkPicImg" style="display: none;" jQuery17102915111663214694="47"/>

Here js code:

var vtk = $("#vtkPicImg");

vtk.bind('mousedown', function(e) {
    e.preventDefault ? e.preventDefault() : e.returnValue = false;
    vtk_mouseDown(e);
    return false;
});

Upvotes: 0

Views: 1914

Answers (1)

user1106925
user1106925

Reputation:

Update

Regarding your updated question, there is no "default" behavior when clicking an <img> element, so naturally there's nothing to prevent.


Since you're using jQuery, all you need is...

e.preventDefault();

Cross browser issues are fixed.

Your trouble is probably that you're doing it on a mousedown event with an element that has no default behavior for mousedown.


To prevent whatever default behavior you're trying to prevent, you'll probably need to do it using the click event.

var vtk = $("#vtkPic");

vtk.bind('click', function(e) {
     e.preventDefault();

})
   .bind('mousedown', function(e) {
        vtk_mouseDown(e);
    });

Upvotes: 2

Related Questions