为什么要拆分<script>使用 document.write() 编写时标记? [英] Why split the <script> tag when writing it with document.write()?

查看:36
本文介绍了为什么要拆分<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> 必须分解,否则会结束封闭的

相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆