I'm trying to set a javascript variable to a html code, but I've noticed something weird. when I write an html tag in a quote (such as body end tag), it formats it as HTML. for example, when I execute the code below in CloudPages:
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title></title>
<meta name="description" content="">
<meta name="viewport" content="width=device-width, initial-scale=1">
</head>
<body>
<script>
function hi () {
var code = "</body>";
document.write(code);
}
window.onload = hi;
</script>
</body>
</html>
My Webpage should contain the "end body tag" text, but instead it looks like this:
like it identifies the "end body tag" as a closing tag, even though it's within a quote. I've also noticed this problem occurs only in CloudPage - When I write this in notepad++ for example and save it as .html, I get the expected result. Does anyone know how to fix this problem?