Javascript - Error When A Script Tag In A String October 26, 2023 Post a Comment I have a page with the following code: '; This results in an error: Uncaught SyntaxError: Unexpected toSolution 1: the error went away when I escaped the / with a \.http://jsbin.com/xugabolu/1/editSolution 2: The hackish work-around for this is something like:<script>window.str = '<scr' + 'ipt></scri' + 'pt>'; </script>CopyIn this way, you wind up with the string you want without confusing the parser.Or, insert it as a DOM element if that is the ultimate goal. Share Post a Comment for "Javascript - Error When A Script Tag In A String"
Post a Comment for "Javascript - Error When A Script Tag In A String"