Reputation: 3029
<!-- Begin: AdBrite, Generated: 2009-08-03 19:56:32 -->
<script type="text/javascript">
var AdBrite_Title_Color = '78B749';
var AdBrite_Text_Color = '000000';
var AdBrite_Background_Color = 'FFFFFF';
var AdBrite_Border_Color = 'CCCCCC';
var AdBrite_URL_Color = '0000FF';
try{
var AdBrite_Iframe=window.top!=window.self?2:1;
var AdBrite_Referrer=document.referrer==''?document.location:document.referrer;
AdBrite_Referrer=encodeURIComponent(AdBrite_Referrer);
}catch(e){
var AdBrite_Iframe='';
var AdBrite_Referrer='';
}
</script>
<span style="white-space:nowrap;">
<script type="text/javascript">
document.write(String.fromCharCode(60,83,67,82,73,80,84));
document.write(' src="http://ads.adbrite.com/mb/text_group.php?sid=1287924&zs=3436385f3630&ifr='+AdBrite_Iframe+'&ref='+AdBrite_Referrer+'" type="text/javascript">');
document.write(String.fromCharCode(60,47,83,67,82,73,80,84,62));
</script>
<a target="_top" href="http://www.adbrite.com/mb/commerce/purchase_form.php?opid=1287924&afsid=1">
<img src="http://files.adbrite.com/mb/images/adbrite-your-ad-here-banner.gif" style="background-color:#CCCCCC;border:none;padding:0;margin:0;" alt="Your Ad Here" width="11" height="60" border="0" />
</a>
</span>
<!-- End: AdBrite -->
I need all this to be escaped, i want it to be uninterpreted by javascript (i know its javascript itself already, but im putting this code inside a different javascript file and i need it to stop breaking the script).
edit: stackoverflow cuts off some of the code. =/ goto http://uber-upload.com, view source, search for "center>
Upvotes: 0
Views: 442
Reputation: 1638
try escaping double quotes.. (in vim: %s/"/\"/g)
document.write("var AdBrite_Title_Color = '78B749'; var AdBrite_Text_Color = '000000'; var AdBrite_Background_Color = 'FFFFFF'; var AdBrite_Border_Color = 'CCCCCC'; var AdBrite_URL_Color = '0000FF'; try{var AdBrite_Iframe=window.top!=window.self?2:1;var AdBrite_Referrer=document.referrer==''?document.location:document.referrer;AdBrite_Referrer=encodeURIComponent(AdBrite_Referrer);}catch(e){var AdBrite_Iframe='';var AdBrite_Referrer='';}\n\n"+"document.write(String.fromCharCode(60,83,67,82,73,80,84));document.write(' src=\"http://ads.adbrite.com/mb/text_group.php?sid=1287924&zs=3436385f3630&ifr='+AdBrite_Iframe+'&ref='+AdBrite_Referrer+'\" type=\"text/javascript\">');document.write(String.fromCharCode(60,47,83,67,82,73,80,84,62));");
Upvotes: 0
Reputation: 1784
Can you use PHP? This SO question has an example of a function that would do the trick.
Upvotes: 0