可能重复:
Why split the <script> tag when writing it with document.write()?
我的网站上应该有一个American Apparel广告,位于右侧栏中,标题为“Bloglovin”和“Twitter”。它似乎在iphone / ipad上正常运行,但它并没有出现在我的计算机上的Firefox或Safari中。如果有人能帮助我,为什么会这样,那将非常感激。
http://www.lookbookcookbook.com/
我正在使用以下代码
<!-- JavaScript for Static HTML -->
<script type="text/javascript">
var mpt = new Date();
var mpts = mpt.getTimezoneOffset() + mpt.getTime();
document.write("<scri" + "pt type=\"text\/javascript\" src=\"http:\/\/altfarm.mediaplex.com\/ad\/js\/8975-64333-44152-3\?mpt=" + mpts + "&mpvc=\"><\/scr" + "ipt>");
</script>
<noscript>
<a href="http://altfarm.mediaplex.com/ad/nc/8975-64333-44152-3">
<img src="http://altfarm.mediaplex.com/ad/nb/8975-64333-44152-3"
alt="Click Here" border="0" />
</a>
</noscript>
答案 0 :(得分:1)
您正在使用CloudFlare的Rocket Script,这意味着您无法使用document.write
(您不应该使用document.write
。)
您需要改为使用document.createElement
。
var script = document.createElement('script');
script.src = "http://altfarm.mediaplex.com/ad/js/8975-64333-44152-3?mpt=" + mpts + "&mpvc=";
document.getElementsByTagName('head')[0].appendChild(script);
编辑:他们的脚本还包含document.write
。除非您关闭“Rocket Script”,否则您无法在页面上实际使用此广告。