Reputation: 155
I am using google ad in my site as given below.
<script type="text/javascript"><!--
google_ad_client = "pub-";
/*Top 468x15 */
google_ad_slot = "";
google_ad_width = 468;
google_ad_height = 15;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
This code is from the admin side which cannot be altered(site architecture is like that), The ad will not displays if the html comment is there, but it displays when i replace the html comment in the js with null before displaying it. Now the problem is if any other html coments are there in the page my str_replace code replaces that too. and the orginal html comment display as plain text. Any solution for this? please help. thanks
Upvotes: 2
Views: 202
Reputation: 5463
I understand that your architecture allows you to do a global search and replace on the complete page and you are replacing just the HTML comment markers <!--
and -->
, right?
Why don't you simply search for the string <script type="text/javascript"><!--
and replace it with just the script tag <script type="text/javascript">
instead? You won't even need to replace the closing selector since it's commented out and should not interfere with any of your script functionality.
Upvotes: 2