I run the following html snippet in IE8 and IE7 with non-English characters (we tried both Hebrew and Chinese), and the second link never works properly.
The displayed text in the alert box is mangled.
This occurs in IE8 and IE7, but not in firefox. It is not dependent on Windows's regional settings.
Here is the html snippet (html header and footer omitted for brevity, the content-type is "text/html; charset=utf-8", and so is the response header):
<p>
<a href="javascript:alert('abשלוםab')">link with English and Hebrew text</a>
<a href="javascript:alert('ab%D7%A9%D7%9C%D7%95%D7%9Dab')">same text, url encoded</a>
</p>
Here is the alert box that pops up when clicking the second link:
I know that the string for "שלום" is encoded as 8 bytes in utf-8, thus there are 8 %NN items, and there are also 8 weird characters in the alert box. The problem is, how can I make IE recognize that this is utf-8 encoding text, like firefox does?
UPDATE:
The full html (of the minimal example) is available here.
I tried decodeURI
, decodeURIComponent
, and unescape
, but without success. Moving the link from href
to onclick
solves the issue. My problem is that some of the content is generated from other sources out of my control, and I ended up with javascript links inside the href attribute.