Hi,
I need to pass some special characters as a parameter in a javaScript function and I want them back in the same format inside my function.
My code is:
<html>
<head>
<script type=“text/javascript” >
function passCharacters(param){
alert('hi!!::: ’ +param);
}
</script>
</head>
<body>
<input type=“button” value=“Click me” onClick=“passCharacters(‘ÓË ×ÀÑÎÂÀ’)” />
</body>
</html>
I get ‘ÓË ×ÀÑÎÂÀ’ in the alert, while I want ‘ÓË ×ÀÑÎÂÀ’ in the alert.
Any help would be appreciated.
Thanks in advance.
I just tried
<html>
<head>
<script type=“text/javascript” >
function passCharacters(param){
alert('hi!!::: ’ +param);
}
</script>
</head>
<body>
<input type=“button” value=“Click me”
onClick=“passCharacters(‘\u00D3\u00CB’)” />
</body>
</html>
But In my alert I again got ÓË, while I want it in decimal format.
Also In my case I am getting this String from server as “#00211;#00203; #00215;#00192;#00209;#00206;#00194;#00192;” , So I cant change it to Unicode:(
In muy problem above both the strings are displayed as ‘ÓË ×ÀÑÎÂÀ’ only.
Rather I am sending the parameter as #00211;#00203; #00215;#00192;#00209;#00206;#00194;#00192; (There is & before every #).
If I add the & before # then wi will display it as ÓË ×ÀÑÎÂÀ, rather I want it in number format
Change the charset to iso-8859-1
Works in all browsers for me.
An alternative is to use Unicode:
passCharacters('\\u00D3\\u00CB ×....')"
The code I have written above is just an example but
In my current scenario, I cant change the charset for the page, but if there is any way to change charset inside a javaScript function, that may help me
Thanks for your reply. Can you please tell me how to do that?
Thanks in advance
I have checked with follwoing code:
<html>
<head>
<meta http-equiv=“Content-Type” content=“text/html; charset=ISO-8859-1”>
<script type=“text/javascript” >
function passCharacters(param){
alert('hi!!::: ’ +param);
}
</script>
</head>
<body>
<input type=“button” value=“Click me”
onClick=“passCharacters(‘ÓË ×ÀÑÎÂÀ’)” />
</body>
</html>
But still I have the same problem
If I add amp; in between every & and # in my parameter, then it works fine.
But I cant even do that.
I tried to use replace to edit my javascript parameter
<xsl:value-of select=“replace({$Str},‘&’,‘&’)”></xsl:value-of>
But I get the error that entityReference & must be followed by entityName