PDA

View Full Version : [OPEN] Unable to stop hyperlink click event in IE11



Greendrake
5 Aug 2015, 12:52 AM
I am trying to use stopEvent: true to prevent the browser from following hyperlinks on clicking them. My attempts are all successful except IE11 in ExtJS 6 and 5 (version 4 works fine!). Note that using native addEventListener and preventDefault works fine too.

Ext.widget({
xtype: 'box',
renderTo: Ext.getBody(),
html: '<a id="link1" href="http://sencha.com" target="_blank">I won\'t work in IE11</a><br><br><a id="link2" href="http://sencha.com" target="_blank">I work everywhere</a>',
listeners: {
boxready: function(box) {
Ext.get('link1').on({
click: function(){},
stopEvent: true
});
document.getElementById('link2').addEventListener('click', function(e) {
e.preventDefault();
});
}
}
});


Fiddle: https://fiddle.sencha.com/#fiddle/rkv

(https://fiddle.sencha.com/#fiddle/rkv)Expected: None of the two links should open when clicked.
Actual: The first link opens in IE11, Ext JS 5 and 6.

Problem occurs in: IE 11.0.9600.17914, Windows7 32 bit.

Gary Schlosberg
5 Aug 2015, 3:28 PM
Thanks for the report! I have opened a bug in our bug tracker.

guilherme.lopes
5 Aug 2015, 7:56 PM
Hi Greendrake,

By default ExtJS translates all mouse events to pointerEvents if they are supported by your browser.
IE10+ converts 'click' to 'tap' and this is where stopEvent() stops working.

Add your listener with the translate: false config.




Ext.get('link1').on({
click: function(){
console.log('Link Clicked');
},
translate : false,
stopEvent: true
});

Greendrake
5 Aug 2015, 9:34 PM
Add your listener with the translate: false config.
Many thanks Guilherme, good stuff.
Searching the translate thing, I found a duplicate (https://www.sencha.com/forum/showthread.php?286719-preventDefault-does-not-work-on-IE10-IE11&p=1048743) of this issue. Still Open for more than a year!

P. S. I would appreciate if my fiddles are not edited by those having superpowers on Sencha Fiddle ;) The Fork option is there.

guilherme.lopes
6 Aug 2015, 1:55 AM
Thanks for reporting the duplicate and sorry about the fiddle, sometimes pressing ctrl+s is faster than the speed of light.

ebarber
6 Jul 2017, 5:14 AM
This appears to be a bug in Chrome Version 59.0.3071.115 (Official Build) (64-bit) using ExtJS 6.5 (Classic). Just ran into it this morning. I tested in Firefox and the first link correctly prevents the browser from following it.