<script type="text/x-jQuery-tmpl">
var gdsize = 1025;
if(window.innerWidth>=gdsize) {
<script type="text/javascript">
<!-- Some javascript here -->
window.cookieconsent_options = {"message":"\"Geek Dashboard uses cookies to make sure you get the best experience on our website.\" -","dismiss":"It's OK","learnMore":"More Details Here","link":"http://www.geekdashboard.com/cookies/","theme":"dark-bottom"};
}
{{html "</sc"+"ript>"}}
</script>
您可以使用{{html "</sc"+"ript>"}}
代替</script>
說明【更新】:
當您在帶引號的(文字)字符串中使用</script>
HTML 標記時,該標記被視為結束標記而不是字符串的一部分。 所以你不能直接在腳本部分中使用</script>
標簽。
一種解決方法是轉義</script>
標簽和/或拆分<script>
標簽:
var scriptEnd = "</scr" + "ipt>";
document.write(scriptEnd);