Alex Jeffrey
Alex Jeffrey

Reputation: 523

Replacing document.write with a jQuery append for script tag

I have an advertising script that generates a 300x250 ad unit, and runs like the following:

document.write('<scr'+'ipt language="javascript1.1" src="[removed]"></scri'+'pt>');

I have to run this script after the page has loaded (on a dialog box) but still in the context of the parent div - I've tried using jQuery to append() both a string and a document.createElement version of this but to no avail. Is there any way to replace this script with a post-load equivalent?

Thanks

Upvotes: 2

Views: 2853

Answers (1)

Alex Jeffrey
Alex Jeffrey

Reputation: 523

Thanks to a tip-off from Bergi, I realised the ad script itself was running document.write. The solution (regardless of how horrible it is):

            document.write = function(str) {
                $('.ad-container').append(str);
            }

Upvotes: 1

Related Questions