Last active
August 29, 2015 13:56
-
-
Save Kanasansoft/9340673 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// JavaScriptを含んだHTMLを評価して返す | |
function evaluateHTML(html) { | |
var iframe = document.createElement('iframe'); | |
document.body.appendChild(iframe); | |
var d=iframe.contentWindow.document; | |
d.open(); | |
d.write(html); | |
d.close(); | |
var result = d.body.innerHTML; | |
document.body.removeChild(iframe); | |
return result; | |
} | |
evaluateHTML('<div id="id"></div><script>document.getElementById("id").textContent="bar"</script>'); | |
// => "<div id="id">bar</div><script>document.getElementById("id").textContent="bar"</script>" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
iframe削除に対応済み。