I want to add a JavaScript snippet into an existing iFrame in the page using jQuery. I have the following code...
Code:
content = \"
The problem is that the HTML parser gets confused if your script contains the closing script tag in it () and it closes the script tag prematurely.
The solution is to escape the / in "<\/script>". This works because strings in JavaScript, (and some other languages), any invalid escape sequences are just ignored, so "\l" is treated as "l", and "\/" is treated as "/". The HTML parser, however, doesn't use a backslash to escape them so it doesn't get confused (credits to https://stackoverflow.com/users/405681/keaukraine).
var scriptTag = "in their code (jsfiddle):var scriptTag = "