문제

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?

도움이 되었습니까?

해결책

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.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top