Google AdSense and XHTML

When working on a new site, I wanted to go web standards all the way. Since I want to use XHTML strict as markup language, that meant serving pages as application/xhtml+xml. Now since IE doesn’t support this, I had to use content negotiation.

So far so good. My pages are supplied as XML in compliant browsers like Firefox and supplied wrongly as HTML in IE. Then I wanted to add Google AdSense ads. I used the wizard who generated some javascript code for me to copy. I copied and pasted it onto my page… result: ads show up nicely in IE but no ads in Firefox. Instead I got a nice javascript error.

Where did I go wrong? I didn’t! The Google javascript normally generates an iframe element, which is not supported by any strict XHTML variants. But there is another problem as well. To generate that HTML code, the javascript uses document.Write(), which isn’t supported by a XML parser javascript code that uses the DOM is needed).

So no valid XHTML (as in content type) until I find a solution…

No Responses to “Google AdSense and XHTML”.

Comments are closed.