HTMLデコード
function decodeHTML(str) {
return str.replace(/&(?:([a-z]+?)|#(\d+?));/g, function(m, c, d) {
return c ? ({
"amp": "&",
"lt": "<",
"gt": ">",
"quot": '"',
"nbsp": " "
}[c] || m) : d ? String.fromCharCode(d) : m;
});
}
decodeHTML("<a onclick="hoge('fuga')">")
// <a onclick="hoge('fuga')">