iamnoah / writeCapture

Utility to assist the Ajax loading of HTML containing script tags that use document.write. Mailing List: http://groups.google.com/group/writecapturejs-users
http://iamnoah.github.com/writeCapture
Other
241 stars 38 forks source link

uncaptured document.write? #12

Closed seanfoo closed 13 years ago

seanfoo commented 14 years ago

This may be unsolvable, but I thought I would mention it.

I have a page that loads an ad, google analytics and a nielsen tracking beacon. I'm trying writecapture on the ad, but I'm running into the document.write('') blank screen in FF. I'm not seeing it in chrome at the moment. http://retro.bb-ref.org/players/j/jeterde01.shtml

Here is the jquery code i'm using.

var ad300 = '<SCRIPT type="text/javascript">\n    <!--\n    var randomNumber = Math.floor(Math.random()*9999999999+1);\n    document.write(\'<scr\' + \'ipt src=http://ad.doubleclick.net/adj/baseballreference.fsv/ros;sect=ros;fantasy=no;game=no;tile=3;sz=300x250;ord=\' + random_number + \'?></scr\' + \'ipt>\');\n// -->\n</SCRIPT>\n';
$('#fm300x250').html($.writeCapture.sanitize(ad300,function() { }));

When this runs in FF I sometimes get the blank screen and here is the response that causes it.

document.write('');

admeld_publisher  = 195;
admeld_site       = 'fsv';
admeld_size       = '300x250';
admeld_placement   = 'ros';
// do not change below

document.write('<scrip'+'t type="text/javascript" src="http://tag.admeld.com/ad/js/' +
admeld_publisher + '/' +
admeld_site + '/' +
admeld_size +'/' +
admeld_placement +
'?url=' + escape(document.referrer) +
'"></scrip'+'t>');

document.write('');

This sets off a cascade of document.writes as we run through a half dozen different js scripts to generate the page.

// here is the first.
document.write(unescape('%3C%21--%20%20Rubicon%20Project%20tag%20--%3E%0A%3C%21--%20%20Site%3A%20Fantasy%20Sports%20Ventures%20%28Safe%29%20%20%20Zone%3A%20My%20Site%20%20%20Size%3A%20Medium%20Rectangle%20%20--%3E%0A%3Cscript%20language%3D%22JavaScript%22%20type%3D%22text%2Fjavascript%22%3E%0Avar%20cb%20%3D%20Math.random%28%29%3B%0Avar%20d%20%3D%20document%3B%0Ad.write%28%27%3Cscript%20language%3D%22JavaScript%22%20type%3D%22text%2Fjavascript%22%27%29%3B%0Ad.write%28%27src%3D%22http%3A%2F%2Foptimized-by.rubiconproject.com%2Fa%2F5941%2F7885%2F13253-15.js%3Fcb%3D%27%2Bcb%2B%27%22%3E%27%29%3B%0Ad.write%28%27%3C%5C%2Fscr%27%2B%27ipt%3E%27%29%3B%0A%3C%2Fscript%3E'));

any help would be greatly appreciated. These damn ads cause the site to hang every once and awhile I'm pretty sure they are driving down pages/visit pretty substantially. My next option is loading them in the footer and moving them.

iamnoah commented 14 years ago

Hmmm, so I can't reproduce the problem. I changed your code slightly:

var ad300 = '<SCRIPT type="text/javascript">\n    <!--\n    var randomNumber = Math.floor(Math.random()*9999999999+1);\n    document.write(\'<scr\' + \'ipt src=http://ad.doubleclick.net/adj/baseballreference.fsv/ros;sect=ros;fantasy=no;game=no;tile=3;sz=300x250;ord=\' + randomNumber + \'?></scr\' + \'ipt>\');\n// -->\n</SCRIPT>\n';

you had + random_number + which I changed to + randomNumber +. I assume that was a typo.

I tried about 20 times but the ad loads fine every time. Maybe I'm just not getting the right random number. It could also be that your domain gets different ad code. So, if you could add two things:

  1. The exact value of randomNumber that causes the problem.
  2. A public facing URL where the problem occurs.

Thanks for the report!

iamnoah commented 13 years ago

Assuming this is resolved. Update with test case if not.