Reputation: 187
I'm trying to add a script that adds an embeddable code to my website, and that code includes the script tag. However, as soon as I add the closing tag, the code stops rendering. Here's what I'm doing before I add the closing tag:
document.getElementById("embed-input").value = '<script> function loadmap() { document.getElementById("mapframe").innerHTML="<iframe width="' + width + '" height="' + height + '" frameborder="0" scrolling="no" marginheight="0" marginwidth="0" src="' + src + '"></iframe> }'
This renders just fine. However as soon as I add that closing tag:
document.getElementById("embed-input").value = '<script> function loadmap() { document.getElementById("mapframe").innerHTML="<iframe width="' + width + '" height="' + height + '" frameborder="0" scrolling="no" marginheight="0" marginwidth="0" src="' + src + '"></iframe> } </script>'
...The code treats it as if I closed the script tags that the above code is contained in, despite the fact that it is contained in quotes. Any idea how get that closing tag to be treated as a string?
Upvotes: 0
Views: 62
Reputation: 2821
Try to use this:-
'<' + '/script>'
Browser sees the script sequence and thinks that this is the end of script tag.
Upvotes: 1