为什么要拆分 <script>用 document.write() 编写时标记?
为什么某些网站(或向客户提供 javascript 代码的广告商)采用将 <script>
和/或 </script>
标记拆分的技术在 document.write()
调用中?
Why do some sites (or advertisers that give clients javascript code) employ a technique of splitting the <script>
and/or </script>
tags up within document.write()
calls?
我注意到亚马逊也这样做,例如:
I noticed that Amazon does this as well, for example:
<script type='text/javascript'>
if (typeof window['jQuery'] == 'undefined') document.write('<scr'+'ipt type="text/javascript" src="http://z-ecx.images-amazon.com/images/G/01/javascripts/lib/jquery/jquery-1.2.6.pack._V265113567_.js"></sc'+'ript>');
</script>
推荐答案
</script>
必须分解,否则会结束封闭的