我有一个来自 XML 的字符串(我无法编辑),我想通过 javascript 中的警报打印它。
我的字符串示例:
This is à string
我需要在警告中打印:
This is à string
有js html解码吗?
最佳答案
即使没有 jquery,您也可以将字符串放在 dom 元素中并再次读取它: https://stackoverflow.com/a/3700369/1986499
根据最近的需求进行编辑,以包含来自另一个 SO 答案的一些代码:
var div = document.createElement('div');
div.innerHTML = encoded;
var decoded = div.firstChild.nodeValue;
关于javascript - javascript警报中的html实体?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14937169/