1

I am trying to putting some Adsense Ads inside a color box and have done below:

jQuery(document).bind('cbox_load', function(){
    var $ads = jQuery('<div style="width:728px; height:90px; background:#fff; position:absolute; top:0; left:0;" id="adsenseColorbox"><script type="text/javascript"><!--google_ad_client = "ca-pub-5435441464221407";/* APRO_728x90_textonly */google_ad_slot = "0595008022";google_ad_width = 728;google_ad_height = 90;//--></script><script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script></div>'); 
    jQuery('#cboxContent').prepend($ads); 
});

the result turns out to be:

<div id="cboxContent"...>
<div style="width:728px; height:90px; background:#fff; position:absolute; top:0; left:0;" id="adsenseColorbox"></div>
...
</div>

Could someone please help to get this Google Adsense work in Colorbox? Thanks.

mdo
  • 69
  • 1
  • 1
  • 7
  • Solved! Using http://stackoverflow.com/questions/3418041/add-javascript-into-a-html-page-with-jquery – mdo May 04 '12 at 22:38
  • Does this answer your question? [add javascript into a html page with jquery](https://stackoverflow.com/questions/3418041/add-javascript-into-a-html-page-with-jquery) – ROOT Mar 20 '20 at 08:23

1 Answers1

0

Try making $ads just a string. Drop the jQuery() bit around it.

Oldskool
  • 34,211
  • 7
  • 53
  • 66
  • `code`jQuery(document).bind('cbox_load', function(){ var $ads = "
    "; jQuery('#cboxContent').prepend($ads); }); `code` @Oldskool but it's not working.
    – mdo May 04 '12 at 21:36
  • Well, no it won't work with that syntax, because you're using double quotes both as the boundaries as well as in the content. Try using single quotes. – Oldskool May 04 '12 at 21:44
  • that will just give me an empty div#adsenseColorbox – mdo May 04 '12 at 21:51
  • Solved! Using this solution: http://stackoverflow.com/questions/3418041/add-javascript-into-a-html-page-with-jquery – mdo May 04 '12 at 22:37