Inline javascript with " – Strelok Sep 08 '12 at 14:21

  • Possible duplicate of [Why split the – David Brossard Nov 24 '18 at 06:01
  • 2 Answers2

    23

    You should always use <\/script> if you want to put </script> in a string in JS, because </script> marks the end of the tag no matter where it shows up.

    Niet the Dark Absol
    • 320,036
    • 81
    • 464
    • 592
    3

    I solved it by splitting the script tag like this SO question recommends:

    doc.write("<scr"+"ipt>var app = \"" + _2d() + "\";</scr"+"ipt>");
    
    Community
    • 1
    • 1
    Robin Rodricks
    • 110,798
    • 141
    • 398
    • 607
    • Don't do that. It is slightly less efficient and significantly uglier then Kolink's solution. (And there is absolutely no need to break up the start tag) – Quentin Sep 08 '12 at 14:30