简体   繁体   中英

Javascript Alert and Confirm not working in IE9 on Windows 7

I have an Windows 7 machine with IE9 and Javascript is not disabled. However, when I use alert or confirm the browser just flickers twice and nothing happens. This is not a code or validation issue as the code works fine in Chrome, Firefox, Opera and Safari. I checked the console and there are no errors.

Does anybody know if there is a way to specifically affect these specific JavaScript functions with some setting? To add more confusion, the prompt function does work, just not alert and confirm.

eg this code sample fails to show an alert.

<script>
  alert('hello');
  document.write('done');
  document.close();
</script>

There are no add-ons and there is no popup blocker

I know this question is OLD but I just had the same problem and found my answer in another post around here so I thought someone else might benefit from this.

Open up the IE developer tool (F12) after your page is loaded.

Check the Browser Mode: and Document Mode:

Try setting Browser Mode to IE9, and Document Mode to IE9 Standards.

Now try again and see if that works.

The original answer.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM