0

I have some code, It works fine on Firefox, Chrome, Safari. Now what would be causing it to not work on IE11. Its JS code, as I missing something here? I was using CONST but have tried changing that, but no go.

$(document).ready(function() {
  var insertBanner = () => {
    var bannerDiv = document.createElement('DIV');
    var insertBanner = bannerDiv;
    var target = document.querySelectorAll('h1')[0];
    bannerDiv.setAttribute('id', ‘insertBanner');
    bannerDiv.innerHTML = "<strong>Your welcome, thanks</strong>";
    target.after(insertBanner);
   
    insertBanner.addEventListener('click', (event) => {
      window.location.href='/thanks';
    });
   };
   insertBanner();
});

Is there some syntax not supported in IE11?

Sole
  • 3,100
  • 14
  • 58
  • 112
  • 1
    https://caniuse.com/#feat=arrow-functions – Dave Newton Jul 06 '20 at 17:02
  • 1
    There should also be an error in your JS console. Almost always worth looking in the console when things don't work. Especially with IE. – Dave Newton Jul 06 '20 at 17:03
  • IE represents about 1.5% of usage. Given that users have to actively "resist" being upgrade to Edge (which does support arrow functions) I personally wouldn't develop for IE any more. – Niet the Dark Absol Jul 06 '20 at 17:04
  • @NiettheDarkAbsol Unfortunately that is not always possible, especially in corporate environments. Heck, it wasn't until two years ago we were "allowed" to drop support for IE9 at one place I worked, and we had to lobby hard just for that. – Dave Newton Jul 06 '20 at 17:07
  • @DaveNewton Sounds rough... I wonder if "We're spending x% more to support less than 2% of our clients" would work as an argument, where "x%" is some significantly higher number than "2%"... (I left the corporate environment and have been a happier dev ever since XD) – Niet the Dark Absol Jul 06 '20 at 17:08
  • @NiettheDarkAbsol About 90% were running IE until we essentially forced then to switch. – Dave Newton Jul 06 '20 at 19:15

0 Answers0