标签:
因为按照嵌入式代码的规则,当浏览器遇到字符串"</script>"时,就会认为那是结束的标签,而通过转义字符"/"可以解决这个问题。
1 2 3 4 5 | <script>window.onload = function(){alert("<\/script>");}</script> |
服务器通常需要看扩展名决定为响应应用哪种MIME类型。如果不使用.js扩展名,请确保服务器能返回正确的MIME类型。
1 2 3 4 5 6 7 8 9 10 11 12 13 | <script type="text/javascript">//<![CDATA[function compare(a, b) {if (a < b) {alert("A is less than B");} else if (a > b) {alert("A is greater than B");} else {alert("A is equal to B");}}//]]></script> |
标签:
原文地址:http://www.cnblogs.com/staven/p/cc5248d8e75482554bc3225bb9d675a3.html