Making AdSense work with XHTML
- 0
- Add a Comment
Have you discovered the consistent problems with using Google’s AdSense with XHTML? It can be a bit bothersome if you are not informed on how to handle it. When using Adsense with XHTML, there are things that you need to be aware of.
For one thing, the javascript being used by Adsense does not work right in pages being served by XHTML pages. Rather than give up on this problem, try some of the techniques listed in this article. Their solution is known to work with most popular browsers.
Google’s AdSense works by using JavaScript to generate an iframe in which to dynamically serve advertisments. This is fine if the page is going to be regular HTML or non-strict versions of XHTML being served as text/html. The JavaScript generates the iframe as expected, and everything works fine and dandy. Unfortunately, for webmasters serving XHTML pages as application/xhtml+xml, the Google method doesn’t work.
The main problem is the JavaScript. The function Document.Write() will not work in correctly served XML pages that are handled by an XML parser. Ian Hickson provides an explanation of why this is the case. As we have already observed, Document.Write() is used to generate the iframe; therefore, the advertisements never appear.
