javascript - Tags written with document.write are not closed properly -


i want insert div tag google tag manager, weird result. situation:

tested browser: chrome (but failure validated external party too)

the google tag manager code

<div>my content</div> <script>   document.write("<div>conetnt in middle</div>"); </script> <div>another content</div> 

the unexpected result (copied dom)

<div>my content   <script>document.write("\x3cdiv\x3econetnt in middle\x3c/div\x3e");</script>   <div>conetnt in middle     <div>another content</div>   </div> </div> 

anyone has idea, why happens?


Comments