我有一个小问题,一直在窃听我,我似乎无法找到一个可行的解决方案。我有一个字符串,它来自以下格式的xml文档。JavaScript - decodeURI渲染为HTML
var str="<p><a href="http://antwrp.gsfc.nasa.gov/apod/ap131120.html"><img src="http://antwrp.gsfc.nasa.gov/apod/calendar/S_131120.jpg" align="left" alt="What are black hole jets made of?" border="0" /></a> What are black &amp; hole jets made of?</p><br clear="all"/>";
我用
var dec = decodeURI(str);
我想呈现为HTML,而不是看我得到下面的输出的输出。
<p><a href="http://antwrp.gsfc.nasa.gov/apod/ap131120.html"><img src="http://antwrp.gsfc.nasa.gov/apod/calendar/S_131120.jpg" align="left" alt="What are black hole jets made of?" border="0" /></a> What are black & hole jets made of?</p><br clear="all"/>
我试图发送此解码数据的HTML文档与
document.write(dec)
和
document.getElementById("output").innerHTML=dec;
该输出有什么问题?我看起来没问题。另外我不认为这是decodeURI的输出......? – Christoph
Youu是正确的decodeURI根本没有改变字符串。感谢指针 – user2040454