سؤال

I would like to load a banner that I know was created with openx, the code of the banner however, contains document.write commands meaning it clears the page when run out of an iframe (document.write clears page) and because my banner is expandable, I wanna load it into a div

Here's the banner's code:

<!--/* OpenX Javascript Tag v2.8.8 */-->    
<script type='text/javascript'>
<!--//<![CDATA[     
var m3_u =    (location.protocol=='https:'?'https://www.aw04.net/ads/www/delivery/ajs.php':'http://www.aw04.net/ads/www/delivery/ajs.php');     
var m3_r = Math.floor(Math.random()*99999999999);     if (!document.MAX_used) document.MAX_used = ',';     
document.write ("<scr"+"ipt type='text/javascript' src='"+m3_u);     
document.write ("?zoneid=299");     
document.write ('&amp;cb=' + m3_r);     
if (document.MAX_used != ',') document.write ("&amp;exclude=" + document.MAX_used);     
document.write (document.charset ? '&amp;charset='+document.charset : (document.characterSet ? '&amp;charset='+document.characterSet : ''));     
document.write ("&amp;loc=" + escape(window.location));     
if (document.referrer) document.write ("&amp;referer=" + escape(document.referrer));     
if (document.context) document.write ("&context=" + escape(document.context));     
if (document.mmm_fo) document.write ("&amp;mmm_fo=1");     
document.write ("'><\/scr"+"ipt>");  *///]]>-->
</script>
<noscript>
<a href='http://www.aw04.net/ads/www/delivery/ck.php?n=a47d7715&amp;cb=INSERT_RANDOM_NUMBER_HERE' target='_blank'>
<img src='http://www.aw04.net/ads/www/delivery/avw.php?zoneid=299&amp;cb=INSERT_RANDOM_NUMBER_HERE&amp;n=a47d7715' border='0' alt='' />
</a></noscript>

Is there a way of loading this script unmodified to something not an iframe?

هل كانت مفيدة؟

المحلول 2

I overwrote the document.write with the following code:

var elementToWrite = null;

document.write = function () {
    if (elementToWrite != null) {
        elementToWrite.append([].concat.apply([], arguments).join(''));
    }
};

Now I just have to set the elementToWrite variable with some element from jQuery, this actually broke a few things but nothing I can't fix from application code

نصائح أخرى

All you need - it's two links (link to <image src="" attribute and link for <a href="" attribute).

So you can get it on your back-end server and returns it as json, for example

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top