|
-
May 22nd, 2002, 08:41 AM
#1
Special characters in DHTML
Hi there !
I'm facing some strange behaviour in respect of displaying special characters like the 'umlauts' in German (ä, ö, ü etc.).
When I'm allocating such a character "statically" within a title attribute of an HTML control, everything works quite fine, e.g.:
<button name="back" style="border:0; background:transparent; cursor:hand" title="R&uuml;ck">
Hovering over this button at runtime unveils a proper "Rück" as the corresponding tooltip. Trying to alter the title contents dynamically via JScript however, doesn't translate the character code into the umlaut:
back.title = "Zur&uuml;ck";
The tooltip then contains "Zur&uuml;ck" instead of "Zurück".
Moreover, an "alert" out of JScript behaves likewise. "alert('Zur&uuml;ck');" activates an IE message box displaying "Zur&uuml;ck". Using the umlaut character directly in the source code ("alert('Zurück');") results in a partly "illegible" string, whereas "alert('&');" (non-masked ampersand) is shown as "&".
It looks like a browser bug !? I'm working with Internet Explorer 6 under WINNT 4.0 SP6a, both German language version.
I'd be grateful for any tips and suggestions. Thanks in advance.
Last edited by HEJ; May 23rd, 2002 at 09:34 AM.
Regards
Hendrik
-
May 23rd, 2002, 06:35 PM
#2
I'm not sure but I suspect that the text is not processed the same when it is used dynamically. I do not know if it is possible to use innerText and/or outerText properties but if it is possible then that is likely to work.
-
May 28th, 2002, 02:21 AM
#3
Obviously, this kind of problem (not only in respect of tooltips/title attribute but of text properties either) occurs when the IE installation is somehow inaccurate, as on other PCs with the same OS and browser (language) version and SP, it doesn't show up. Unfortunately, we couldn't figure out so far the exact reason for this strange behaviour of (non)processing special characters. The only "remedy" is likely to completely remove the IE and install it anew.
The "innerText" and "outerText" approach apparently doesn't solve the problem, but nontheless "Thanks" for the advice !
Regards
Hendrik
-
October 14th, 2002, 05:07 PM
#4
If you want to alter the contents dynamically and still have the ability to retain character entities, why not read the values from hidden form fields. Try out the sample code below, and press the "Change Text" button several times.
<html>
<head>
<script language="JavaScript">
function changeText(){
if (document.myform.back.value == document.myform.foo.value) {
document.myform.back.value = document.myform.foo2.value;
} else {
document.myform.back.value = document.myform.foo.value;
}
}
</script>
</head>
<body>
<form name="myform">
<input type="hidden" name="foo" value="R&uuml;ckseite" />
<input type="hidden" name="foo2" value="Gehen Sie" />
<input type="button" value="Change Text" onClick="changeText()" />
<button name="back" style="border:0; background:transparent; cursor:hand" title="Gehen Sie" />
</form>
</body>
</html>
-
October 14th, 2002, 06:42 PM
#5
the only problem is that ie does special character interpretation when the page first opens, it won't evaluate it after that. So, do this:
Code:
<html>
<head>
<script language="JavaScript">
var someText="rück";
</script>
</head>
<body>
<script language="JavaScript">
document.writeln(someText);
</script>
<br>
same as rück
</body>
</html>
and yes i've tested this code, so whenever you need to write some special text dynamically, just load it in a variable in the head section, then you can use it later.
edit: the ü symbol in the above code should actually be the code for it, it parses it here and i'm not sure how to stop it, but otherwise the code works.
Last edited by Waldo2k2; October 14th, 2002 at 06:45 PM.
C G C F A D--Feel the Noise
"When your life goes nowhere and leads back to me, doesn't that tell you something?"
~Gray Area Fury
-
October 14th, 2002, 07:21 PM
#6
Originally posted by Waldo2k2
edit: the ü symbol in the above code should actually be the code for it, it parses it here and i'm not sure how to stop it, but otherwise the code works.
I am not sure I understand what you want to do but one way to enter the "ü" character symbolically is to use "&uuml;" in this forum's software and in HTML.
-
October 14th, 2002, 09:50 PM
#7
Originally posted by waldo2k2 edit: the ü symbol in the above code should actually be the code for it, it parses it here and i'm not sure how to stop it, but otherwise the code works.
If you want to see the character ü then type in &uuml;
If you want to see &uuml; then type in the character entity for & and then type in uuml;
-
October 14th, 2002, 10:09 PM
#8
Originally posted by websmith99
If you want to see &uuml; then type in the character entity for & and then type in uuml;
To get "&" type "&amp;". So if you want "&uuml;" to be shown then type "&amp;uuml;".
-
October 14th, 2002, 10:30 PM
#9
Exactly what I was trying to convey- but Sam Hobbs put it more eloquently.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|