From bcf3be2e38ab96a41118a23e7e96db59655de733 Mon Sep 17 00:00:00 2001 From: Kai Moritz Date: Tue, 25 Sep 2012 12:17:54 +0200 Subject: [PATCH] Fixed an error in the ordering, output added via document.write is rendered Because output added by an ad-script via document.write() was always prepended to the unrendered rest of the banner-code, the order of the markup was messed up, if an ad-script called document.write() more then once! --- openx.js | 40 +++++++++++++++++++++++++++------------- 1 file changed, 27 insertions(+), 13 deletions(-) diff --git a/openx.js b/openx.js index a01c775..3499345 100644 --- a/openx.js +++ b/openx.js @@ -12,7 +12,8 @@ count = 0, slots = {}, queue = [], - ads = []; + ads = [], + output = []; openx.show_ads = function(server, zones) { @@ -73,6 +74,8 @@ while (ads.length > 0) { + var result, src, inline, i; + id = ads.shift(); node = slots[id]; @@ -80,7 +83,17 @@ // node.append(id + ": " + node.attr('class')); - var result, src, inline; + /** + * If output was added via document.write(), this output must be + * rendered before other banner-code from the OpenX-server is rendered! + */ + if (output.length > 0) { + output.push(OA_output[id]); + OA_output[id] = ""; + for (i=0; i