을 document.writing 때 현재 스크립트 블록 끝나지 필요 '...<scr'+'ipt>'
더 유용하고 중요 하나 인은 </script>
못해 이 스크립트 태그를 종료하기 때문에 스크립트 어디에서나 나타납니다
<script type="text/javascript">
var a = "<script>alert('hello world');
</script>
";
<script></script>
:
<script type="text/javascript">
var a = "<script>alert('hello world');</script>";
</script>
더 많은 이하로 처리됩니다
html 파서의 눈에는.
<script type="text/javascript">
var a = "<script>alert('hello world');<\/script>";
</script>
이는 document.write
관련이 없습니다 기술적으로 전혀은 document.write
이입니다 단지입니다 : mplungjan처럼
는이 복잡한 방법이며 하나 만들 리터럴 자바 스크립트 문자열 단순히 <\/script>
가 작동 할 수 말했다 당신이 필요로하는 일반적인 장소 "</script>"
자바 스크립트 문자열 리터럴.
또한 "<script>"
은 사실 그대로 전체적으로 훌륭합니다. 코드에서 자른 문제는 단지 "</script>"
입니다.