Stop Event in IE 9 (without upgrading to Prototype 1.7)

The site I'm working on uses Prototype 1.6.1. Its Event.stop() doesn't work in IE9. I know that Prototype 1.7 fixes the problem. However, is there a walk-around if I cannot upgrade to Prototype 1.7?

I need the site to be compatible with IE 7, 8 and 9 (as well as Chrome, Firefox, etc).

Thanks!

EDIT: I tried event.preventDefault() and it doesn't work for me in IE 9. Here is an example: http://jsfiddle.net/garthcn/AdR7g/ It works in jsfiddle/Chrome/Firefox. If you paste the code to an HTML file and open it with IE9, it won't work.

EDIT2: I just found that Prototype 1.6.1 adds its own preventDefault() method to IE which doesn't work on IE 9. However, IE 9 comes with its own preventDefault() which actually works. So if I stick to Prototype 1.6.1, I guess I cannot get preventDefault() to work on IE 9.

Answers


function stopDefAction(evt) {
     evt = evt || event;
     if (evt.preventDefault) {
          evt.preventDefault();
     }
     else {
          evt.returnValue = false;
     }
}

It seems like internally Prototype does extend, which - under IE9 - breaks things. Without upgrading, the easy thing would be to add an x-ua-compatible meta tag at the tippy top of your head tag (but below the charset tag) to force IE9 into being IE less than 9.

If you have the ability, you could also try patching Prototype directly: http://mandagreen.com/prototype-1-6-event-stop-ie9-quick-patch/ This was written for 1.6.0, but I think it should work for 1.6.1. I have the same problem and will likely be trying it out to see what happens.


Need Your Help

Getting the Out of Office status programatically from Exchange or AD?

c# .net outlook exchange-server

When people use Outlook (in this case in a Windows AD Domain running Exchange 2003 and 2007), they can set an Out of Office reply. Office Communicator 2005 can access it as well, so I assume there ...

Adding an image where user touchs ipad

jquery ipad html5 touch

Was hoping someone could help me out, Is i possible to place and image where a users touches the screen on an ipad? I'm trying to create a little game(HTML5 javascript) which as 5 or so objects(ima...