Firefox, xhtml, JBoss 4.2.0, JSF, and Google Ads
I upgraded the JBoss instance on my server just over a week ago from 4.0.5 to 4.2.0. Two things happened after that: Firstly, my google adsense revenue dropped by half, secondly I was contacted by two different people who were having some e-mails show a big error in Firefox, instead of showing up correctly. I don't use Firefox myself, I use Safari about 98% of the time and Camino when I find a site that doesn't render correctly in Safari. Today I discovered, while working on a new ad layout, that in Firefox the Google ads weren't rendering at all, throwing this error in the Firefox error console:
Error: uncaught exception: [Exception... "Object cannot be created in this context" code: "9" nsresult: "0x80530009 (NS_ERROR_DOM_NOT_SUPPORTED_ERR)" location: "http://pagead2.googlesyndication.com/pagead/show_ads.js Line: 4"]
Basically iframes can't be programatically inserted into strict xhtml elements. I did some googling and discovered that there were some discussions around this, but most of them simply said "either ditch google ads, or use text/html instead." But I WAS using text/html, both in the meta content tag in the pages, and then later (while working on this issue) in the JBossWeb web.xml mime type configuration for xhtml, just in case. Using wget with --save-headers didn't show anything unexpected. However, Firefox kept getting the response header saying the page was application/xhtml+xml which caused it to perform very strict validation, both breaking the google ads, and not letting sloppy tags or duplicated tags into the page, which are inherently going to happen when you're rendering html e-mail within a page.
The cause of the break was not moving to JBossWeb in 4.2.0, nor any JBoss code itself. It turns out that when the JSF implementation was changed from MyFaces to Sun's JSF-RI as part of the JBoss and Seam upgrade I did, the default content mime type changed as well. JSF-RI sets it to application/xhtml+xml. The fix was simple, add the following tag just before the <head> tag in each .xhtml faclets page:
<f:view contentType="text/html"/>
December 9th, 2007 at 11:54 pm
Hi,
its of great help I was facing the same problem but now its working after adding also I found if i add it resolves the issue for me I was surprised why is it so?
Any ways Thanks for post!!
February 9th, 2008 at 5:53 pm
Worked perfectly. Thanks Devon.
March 4th, 2008 at 4:22 pm
[…] You can solve this the same way you solve the JSF/Google Ad issue: […]
March 23rd, 2008 at 6:03 am
Wicked, that solved the problem for me too. Much appreciated.
June 14th, 2008 at 11:50 am
Please, if you have time, check this images: http://lagatafritz.deviantart.com/art/Ads-across-ART-88652722 and http://lagatafritz.deviantart.com/art/Why-I-will-leave-Deaviant-Art-88650391
Something like this happen to me while using Firefox at Deaviantart.com
June 27th, 2008 at 4:04 pm
Damm…that was simple…..tried iframe,object and all kinda stuff….didnt expect it to be so easy to fix
Thanks