开发者

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 pr开发者_开发技巧ototype methodology for use in IE9?


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'


Change document mode to IE8 standards by putting the following tag inside <head></head>:

<meta http-equiv="X-UA-Compatible" content="IE=8" />
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜