Javascript call after dom completes
We use an external system to serve ads on our site. Currently, in our header files, we have js that uses jquery to insert data into our ad holder, which is a div that appears on every page, i.e.
$("#adSpot").prepend('put my ad here');
Our third party ad system just started using Google Ad Server another system to serve ads, so now we have provided us with a JS to call. I would like to use our header files and do not have to touch every file, but I am unable to insert the js which is then executed like this:
$("#adSpot").prepend('GA_googleFillSlotWithSize("ca-pub-981", "Page_1", 468, 60)');
Basically, I would like to use a header file, so when the page loads, it injects this js code into the div where we want the image to be positioned, and then js is executed to make the image appear in the spot. Now it is pushing the code to the div but the js is not executed.
Thank!
Don't understand why you are doing this, but seeing that you insist on putting JavaScript in a div, have you tried wrapping it in a script tag and adding it to a div?
$("#adSpot").prepend('<script type="text/javascript">GA_googleFillSlotWithSize("ca-pub-981", "Page_1", 468, 60)</script>');
source to share