jquery代码插入googleads里面(.after)

时间:2016-10-15 07:40:54

标签: javascript jquery

jquery代码插入googleads里面 下面是我的js代码,需要将google广告代码放入到 jquery .after()或.html()
但它不起作用..

未捕获的SyntaxError:无效或意外的令牌

<script>    
$(document).ready(function(){
 var  content = $('.cldesc').find('p, br,div');
 var  midLength = parseInt(content.length/2);
 content.eq(midLength).after('<div class="advbg"><ins class="adsbygoogle" style="display:block" data-ad-client="ca-pub-8239618654141130" data-ad-slot="6511565608" data-ad-format="auto"></ins><script>(adsbygoogle = window.adsbygoogle || []).push({});</script></div>'); });
</script>

1 个答案:

答案 0 :(得分:1)

您可以破解您的PHP代码并插入AD的HTML代码。

<?php
//your PHP code
?>

//your advertisement code
div class="embeddedContent oembed-provider-youtube" data-align="none" data-oembed="youtube.com/watch?v=EEzTBCLS7hE"; data-oembed_provider="youtube" data-resizetype="noresize">
<iframe... YOUR ADS CODEallowfullscreen="true" allowscriptaccess="always" frameborder="0" height="349" scrolling="no" src="youtube.com/embed/…; width="425"></iframe>
</div>

<?php
//your PHP code
?>