This question already has an answer here:
- Can scripts be inserted with innerHTML? 16 answers
<!DOCTYPE html>
<html>
<body>
<p>Click the button to trigger a function that will output "Hello World" in a p element with id="demo".</p>
<button onclick="myFunction()">Click me</button>
<p id="demo"></p>
<script>
function myFunction() {
document.getElementById("demo").innerHTML = "'Python\x20Auto\x20\x3Cscript\x20type\x3D\x22text\x2Fjavascript\x22\x3E\x20alert\x28\x22JavaScript\x20alert\x22\x29\x3B\x20\x3C\x2Fscript\x3E\x20'";
}
</script>
</body>
</html>
!!!Please see the comment below, also, please make your question a bit more clear!!!
Instead of using
\x3C
you can use<
because somehow it is escaping rest of the string,Need to use < for <, > for >, and \" for ". Everything else should be fine to use the actual characters, see below.