文字列パラメーターを使用した JavaScript メソッド呼び出しがあります。文字列テキストには、HTML 文字参照が含まれていることがあります。たとえば'
、予期しない識別子エラーが発生します。文字参照があれば、"
うまくいきます。それがなぜなのかわかりません。以下は、私がやろうとしていることのコードスニペットです。実際の方法ははるかに長く、ここで示したものとは異なることを試みていますが、このスニペットでエラーを再現できるはずです。
<script>
function unescapeHTML(html) {
var htmlNode = document.createElement("div");
htmlNode.innerHTML = html;
if(htmlNode.innerText)
alert htmlNode.innerText; // IE
else
alert htmlNode.textContent; // FF
}
</script>
<a class="as_Glossary" onmouseover="unescapeHTML('The manufacturer's sales in dollars to all purchasers in the United States excluding certain exemptions for a specific drug in a single calendar quarter divided by the total number of units of the drug sold by the manufacturer in that quarter'); return true;" onmouseout="hideGlossary(); return true;">Test</a>
マウスオーバーするとエラーが発生します