Is there a sequence of characters that can be used after malformed javascript code, to ensure the subsequent script will be executed?
The idea being that we have separate divisions writing javascript code that will be placed on the same page. The "other" group are notorious for leaving bad code around. Since my code will be in the footer (via site.master), what set of characters can I use to ensure (or make it more likely) that my code will be executed?
Example
// > "" ; */
alert("this code will always run, regardless of what happens before...");
None is defined in EcmaScript itself. A syntactically invalid program will not run at all.
In HTML, </script><script>
will close the current SCRIPT and open a new one, and the failure of one SCRIPT element's content to parse does not cause other SCRIPT elements' content to fail to parse since they are distinct programs.
If the preceding content is always a line comment, as in your example, any line terminator will suffice, and the EcmaScript line terminators are
U+A \n
U+D \r
U+D,U+A \r\n
U+2028 Line separator
U+2029 Paragraph separator
according to section 7.3 of the spec.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With