Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Disable a link in IE9 - prototype stop() not working

IE9 is still in Beta, but all the same, here is a question:

Using prototype.js 1.6.1, proper form for adding a click event to a link, and override the default link behavior, would be:

mylink.observe('click', function(e){
   doSomething();
   e.stop();
});

While this works perfectly in every other browser that I tried, IE9 is a unique case. The default event behavior fires and my link takes me to the linked location. It seems that stop() isn't doing its job in IE9.

The following code works perfectly in IE9:

mylink.onclick = function(){
   doSomething();
   return false;
}

Any idea what I could do to fix the prototype methodology for use in IE9?

like image 590
Gromeen Avatar asked Oct 12 '10 21:10

Gromeen


1 Answers

prototype.js versions less than 1.7 does browser-sniffing to apply cross-browser compatible fixes.

prototype.js overwrites the native methods with it's implementation, which fails in IE 9; even-though it has support for DOM Level 2 Events.

The newer version of prototype.js doesn't have this issue as it does 'feature detection' rather than 'browser-sniffing'

like image 199
Livingston Samuel Avatar answered Nov 11 '22 07:11

Livingston Samuel