I want to put "</script>
" in a variable in JavaScript but it will be consider as end tag like below example:
<script>
content.value = aval + '<script> ma_gallery("' + varimgurl + '");</script>'+ sevom;
</script>
Does anyone know a solution ?
I want to put "</script>
" in a variable in JavaScript but it will be consider as end tag like below example:
<script>
content.value = aval + '<script> ma_gallery("' + varimgurl + '");</script>'+ sevom;
</script>
Does anyone know a solution ?
Share Improve this question asked Jul 22, 2014 at 16:03 SamSam 1,5791 gold badge14 silver badges29 bronze badges2 Answers
Reset to default 17Use '<\/script>'
.
In a string literal, an escaped slash is equivalent to a slash so it makes no difference to the JavaScript parser but it breaks up the end tag syntax so it isn't parsed as an end tag by the HTML parser.
(An alternative is to split it up into two strings and concatenate them together, but that is more typing, harder to read, and (albeit not significantly) less efficient).
Split "</script>"
into two strings:
content.value = aval + '<script> ma_gallery("' + varimgurl + '");</scr' + 'ipt>' + sevom;
发布者:admin,转转请注明出处:http://www.yc00.com/questions/1744146656a4560455.html
评论列表(0条)