Internet Explorer Ampersand Bug with prompt()

I just discovered an inconsistency in how Internet Explorer (6 and 7) handles ampersands with the prompt() built-in function.

Try the following in Firefox and then again in IE6 or IE7.

<html>
  <script>
    alert('-&-');
    alert('-\&-');
    alert('-&&-');
    prompt('-&-');
    prompt('-\&-');
    prompt('-&&-');
 </script>
</html>

FF and IE behave identically for alert() but for prompt() both IE6 and IE7 fail to show an ampersand unless "&&" is supplied. Very strange.

In case you're wondering, &amp; doesn't help either; it isn't translated for popups in any of the browsers.

Is this a known problem? I haven't been able to track down other reports of the issue.

Short of doing browser specific hacks, or just not using prompt(), I can't see a way of getting consistent behaviour across browsers. How craptastic. The joys of web development...

Comments

Comments powered by Disqus