-1

Possible Duplicate:
Why split the <script> tag when writing it with document.write()?

There is supposed to be an American Apparel advertisement on my site, in the right hand side bar, in between the headers "Bloglovin" and "Twitter". It seems to function fine on the iphone/ipad, but it doesnt show up on my computer in Firefox or Safari. If anyone could help me as to why this is, it would be much appreciated.

http://www.lookbookcookbook.com/

I am using the following code

<!-- 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>
Community
  • 1
  • 1

1 Answers1

1

You're using CloudFlare's Rocket Script, which means you can't use document.write (you shouldn't use document.write anyway).

You need to use document.createElement instead.

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);

EDIT: Their script also contains a document.write. You can't actually use this ad on your page, unless you turn "Rocket Script" off.

gen_Eric
  • 223,194
  • 41
  • 299
  • 337