禁用IE9中的链接 - 原型stop()不起作用 [英] disable a link in IE9 - prototype stop() not working
问题描述
IE9仍处于测试阶段,但同样如此,这是一个问题:
IE9 is still in Beta, but all the same, here is a question:
使用prototype.js 1.6.1,正确的表单添加点击事件到一个链接,并覆盖默认的链接行为,将是:
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();
});
虽然这在我尝试的其他所有浏览器中都能很好地运行,但IE9是一个独特的案例。触发默认事件行为,我的链接将我带到链接的位置。似乎stop()没有在IE9中完成它的工作。
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.
以下代码在IE9中完美运行:
The following code works perfectly in IE9:
mylink.onclick = function(){
doSomething();
return false;
}
我知道如何修复原型方法以便在IE9中使用?
Any idea what I could do to fix the prototype methodology for use in IE9?
推荐答案
prototype.js版本低于1.7会浏览器嗅探以应用跨浏览器兼容的修补程序。
prototype.js versions less than 1.7 does browser-sniffing to apply cross-browser compatible fixes.
prototype.js用它的实现覆盖本机方法,在IE 9中失败;偶数 - 虽然它支持DOM Level 2 Events。
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.
较新版本的prototype.js没有这个问题,因为它的'特征检测'而不是'浏览器嗅探'
The newer version of prototype.js doesn't have this issue as it does 'feature detection' rather than 'browser-sniffing'
这篇关于禁用IE9中的链接 - 原型stop()不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!