Last active
December 28, 2019 11:49
-
-
Save WilliamsJack/574eba409fb42115772af05a5cd3f39d to your computer and use it in GitHub Desktop.
This file contains 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
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta charset="UTF-8"> | |
<title>JS Insert Test</title> | |
</head> | |
<body> | |
<button id="insert" onclick="insertFunction();">Insert JS</button> | |
<script> | |
function insertFunction() { | |
var html = document.createElement( 'div' ); | |
html.id = 'inserted-html'; | |
html.innerHTML = 'A loop provided by inserted JS will now generate some numbers:' | |
document.body.appendChild(html); | |
var script = document.createElement( 'script' ); | |
script.type = 'text/javascript'; | |
script.innerHTML = 'alert("Arbitrary Javascript inserted!");var i;for (i = 0; i < 10; i++) {var e = document.getElementById("inserted-html");var p = document.createElement( "p");p.innerHTML = i;e.appendChild(p);e.appendChild(p);}' | |
document.head.appendChild(script); | |
} | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment