views:

17

answers:

1

Hi All, I am trying to display google ads on xhtml file, but chorme browser down't show them up. The ads show on all other browsers I tried (Ie,firefox,opera) but chrome. Has anyone encountered this before? Small sample code:

    <html xmlns="http://www.w3.org/1999/xhtml"&gt;
   <body>
<script language="javascript">

 google_ad_client = "pub-4942221729702985";
 google_ad_slot = "0095628928";
 google_ad_width = 728;
 google_ad_height = 90;
 </script>
 <script language="javascript"
 src="http://pagead2.googlesyndication.com/pagead/show_ads.js"&gt;
 </script>
 </body>
   </html>

Thanks Smitha

A: 

The problem is google js file uses document.write, which is not allowed in a application/xhtml+xml page

I guess this will solve your problem

http://www.cromwell-intl.com/technical/google-adsense-and-xhtml.html

http://ejohn.org/blog/xhtml-documentwrite-and-adsense/

http://randsco.com/index.php/2005/11/10/serving_xhtml_with_the_right_mime_type

The W3C recommends that ALL XHTML documents be served as "application/xhtml+xml". This is because XHTML requires more strict validation and the code doesn't contain the myriad of diverse tags (AKA "tag soup") that need be supported in "text/html" (one benefit is that XHTML renders faster).

vsingh
Thanks a lot for your response. It worked for me as explained in the link: http://www.cromwell-intl.com/technical/google-adsense-and-xhtml.html. Thanks once again!Smitha
Smitha

related questions