简体   繁体   English

Javascript字符串不支持特殊字符

[英]Javascript strings not supporting special characters

I have an HTA with 3 frames which overall looks like this: 我有3帧的HTA,总体看起来像这样:

<html>
<head>
<script type="text/javascript">
     function f(){
          frames["toolbar"].document.write("Toolbar");
          frames["statusbar"].document.write("Status bar");
     }
</script>
<frameset rows="65,*,19" onload="f()">
     <frame src="about:blank" name="toolbar" application="yes"/>
     <frame src="url.html" name="main" application="yes"/>
     <frame src="about:blank" name="statusbar" application="yes"/>
</frameset>
</html>

Note: The content of the toolbar and statusbar frames are more complicated than what's specified here. 注意:工具栏和状态栏框架的内容比此处指定的更为复杂。

Notice that two frames are defined using JavaScript and don't have a real URL. 请注意,两个框架是使用JavaScript定义的,没有真实的URL。

Since this HTA is in Swedish, i need to use Swedish special letters which are å, ä and ö, for example alert("Du är inte uppkopplad") . 由于此HTA是瑞典语,因此我需要使用å,ä和ö等瑞典语特殊字母,例如alert("Du är inte uppkopplad") The problem is that in the toolbar frame and in the statusbar frame which the content has been defined in JavaScript, this alert box looks like this: 问题在于,在已经在JavaScript中定义了内容的工具栏框架和状态栏框架中,此警报框如下所示: 在此处输入图片说明

It replaces ä with an ugly square in the toolbar frame and in the statusbar frame, but not in the main frame (which has a real URL). 它在工具栏框架和状态栏框架中用丑陋的正方形代替ä,但是在主框架(具有真实URL)中则用丑陋的正方形代替。 How do I fix this? 我该如何解决?

It works if I create a variable in the parent HTA which takes the value ä like this: 如果我在父HTA中创建一个变量,它的值ä如下所示,它将起作用:

Main HTA: 主要HTA:

<html>
<head>
<script type="text/javascript">
     function f(){
          frames["toolbar"].document.write("<script type='text/javascript' src='script.js'><\/script>");
          frames["statusbar"].document.write("Status bar");
     }
     var a = "ä"
</script>
<frameset rows="65,*,19" onload="f()">
     <frame src="about:blank" name="toolbar" application="yes"/>
     <frame src="url.html" name="main" application="yes"/>
     <frame src="about:blank" name="statusbar" application="yes"/>
</frameset>
</html>

script.js: 的script.js:

alert("Du " + parent.a + "r inte uppkopplad");

Thanks to t.niese for giving me the idea in a comment. 感谢t.niese在评论中给我提出了这个想法。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 在javascript中使用数字和特殊字符对字符串进行排序 - In javascript sorting strings with numbers and special characters 用于JavaScript的正则表达式,用于测试字符串,数字和特殊字符 - Regex for javascript to test strings, number and special characters 如何在忽略特殊字符的javascript中比较字符串 - How to compare strings in javascript ignoring special characters 如何替换Javascript中的所有字符串? 特别是结合特殊字符 - How to Replace all strings in Javascript? In particular with Combination of special characters Javascript-删除Json对象中的特殊字符和关联的字符串 - Javascript - Remove Special characters and associated strings in Json object 根据特殊字符和换行符将字符串拆分为多个字段 - Javascript - Split strings into multiple fields based on special characters and newline - Javascript 如何使用javascript正则表达式删除带有数字和特殊字符的字符串? - How to remove strings with numbers and special characters using javascript regular expressions? 清理字符串以避免特殊字符破坏由php生成的javascript - Sanitize strings to avoid special characters break javascript generated by php 传递具有特殊字符的字符串 - Passing strings having special characters 解码Javascript中的特殊字符 - Decoding special characters in Javascript
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM