0

Essentially, I have a script tag within my script.

(generic HTML)
<script>
function asdf(){
    document.getElementById('jkl').innerHTML = "<script>(another script goes here)</script>"
}
</script>
(generic HTML) 

Unfortunately, the first </script> tag is listened to, not the second. Is there any way to "comment" it, like butting a back slash in front of quotes?

2
  • What exactly are you trying to do? There's probably a better way. Commented Nov 23, 2013 at 13:13
  • Possible duplicate of stackoverflow.com/questions/1659749/… Commented Nov 23, 2013 at 13:23

1 Answer 1

3

You need to break your inside script string into two pieces like this:

<script>
function asdf(){
    document.getElementById('jkl').innerHTML = "<script>(another script goes here)</scr" + "ipt>"
}
</script>

Otherwise the HTML parser will think that the inner </script> closing tag is closing the opening tag, and this will cause problems.

Sign up to request clarification or add additional context in comments.

1 Comment

Thanks a lot, mate! I didn't think of it that way :P

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.