Google Maps + XHTML1.1
As described in another post tonight I wanted XHTML1.1 compliance in my content management system. There was also a need for a map based location. Google Maps mashup time… Only one problem, XHTML1.1 compliance means using the application/xhtml+xml mime type. Google Maps uses the JavaScript function document.write(), and wouldn’t you know it, that function does not exist in the xml dom api.
Seems I’m not the only one with this issue: Google Maps API – No XHTML Support. I couldn’t actually find any such references on the Google Maps Help Group, I didn’t look to hard though. Why? Because I found lots of information in other areas. If you follow some links from the following you will have more than enough information.
- John Resig discusses the issue and presents a solution. AdSense related.
- Thread on Google Maps API Group.
I tried the solution presented by John Resig. No dice. I think this may be related to the differences in AdSense and Google Maps.
The CMS already used jQuery extensively, so perhaps jQuery could help. It’s funny this is extremely simple, but it works:
<script type="text/javascript" src="/js/jquery.js"></script>
<script type="text/javascript">
//<![CDATA[
// Especially overwritten for xhtml+xml content type
document.write = function(str) { $("head").append(str); };
//]]>
</script>
Ok, claiming that works is silly:
- It works in Firefox, IE6+, Opera* and Konqueror.
- I have not tested it in Safari, it did work with Konqueror though.
- It depends on the jQuery library (it might work with Prototype).
- * You have to serve text/html to Opera. It appears Opera doesn’t support executing JavaScript added in this fashion, be it external files or inline code.
If anyone can test under Safari that would be excellent.
Andrew
Rickshaw Run
In Jan 2010 I participated in the Rickshaw Run 2010 Winter Edition; you can read all about the adventure and my teams participation...$30 Food Challenge
In Feb 2009 I attempted to "eat with $30 for a week"; the run down starts here...
Tags
3G apple asterisk bigpond boring coding design facebook food challenge howto internet kvm life linux login mobile multiwan nat nbn networking NextG on a hill openvpn pfsense politics project management question random revival centres revival centres rickshaw router server2008 smoothwall spiritual study aid telstra thought trac travel tutorial what the windows windows7 wordpress

Login Options
Enter your WordPress.com blog URL
http://.wordpress.com
Proceed