-5

JavaScript is not working on Internet Explorer 11 - even a simple alert() is not working, unless debugging mode (F12) is on.

I'm not using any console/log related code lines.

<script type="text/javascript" src="./Common/JS/jquery-2.1.1.min.js"></script>
<script type="text/javascript" language="javascript">
    $(document).ready(function () {
       alert('HERE');
    });
</script>

Console Error:

Object doesn't support property or method 'addEventListener'

I know that this question has been asked multiple times but even in the comments people are saying that suggested solutions didn't work with IE 11

  • 1
    Please show an example of the non-working JavaScript and HTML. – Herohtar Dec 31 '18 at 18:41
  • @Herohtar just did – Marwah Abdelaal Dec 31 '18 at 18:45
  • 1
    We need a [mcve] to help you, with emphasis on "complete". –  Dec 31 '18 at 18:46
  • Previous versions of IE developer tools will not work on IE11. Uninstall any previous tools (especially standalone version installations) if (still) present, and make a fresh (re)install of the latest IE11 download. Don't try to install IE tools over IE11 installation separately because they are already threre as a part of IE11 installation. Doing so will make a conflict that will reflect in experienced result. Reboot the computer even if not prompted. Good luck – IMParasharG Dec 31 '18 at 18:47
  • Please show the full (but minimal) HTML document, otherwise we can't tell where possible problems are. – Herohtar Dec 31 '18 at 18:48
  • Perhaps related to [this question](https://stackoverflow.com/questions/25077612/jquery-not-working-with-ie-11)? – Herohtar Dec 31 '18 at 18:50
  • @MarwahAbdelaal Are you getting errors in your browser console? –  Dec 31 '18 at 18:53
  • @Amy Object doesn't support property or method 'addEventListener' – Marwah Abdelaal Dec 31 '18 at 18:59
  • @MarwahAbdelaal That's an important detail that should be in your question. –  Dec 31 '18 at 19:00
  • I suspect what is happening is your site is running in an older compatibility mode until you open your dev tools, which is then setting the document mode to one that doesn't support `addEventListener`. –  Dec 31 '18 at 19:03
  • @Amy I changed to jquery 3.1.1 and i'm getting a different error: Unable to get property 'createElement' of undefined or null reference, any suggested version – Marwah Abdelaal Dec 31 '18 at 19:17
  • jQuery is supposed to be compatible with IE 9 and higher. Do you have IE11 set to Compatibility mode? This will disable newer features. – Barmar Dec 31 '18 at 19:33
  • @Barmar no, I don't have it set to compatibility mode – Marwah Abdelaal Dec 31 '18 at 19:41

1 Answers1

0

this line solved my issue, just make sure to add at the top of your head tag

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

Thanks to this answer https://stackoverflow.com/a/6771584/6240803