Saturday, November 11th, 2006
Because Google AdSense depends on document.write, the net result is that I only serve ads to users of browsers that donâ€™t support XHTML, which increasingly means that only IE users see ads.
The solution is to use createElementNS instead. So far, so good. The only piece left to the puzzle is where to append the child that you created. If you simply do a document.appendChild, the new element ends up at the end of the document. There doesnâ€™t seem to be a property which indicates the current node in the tree at the time of the parse. But in cases like adsense, you generally want the widget put in place.
- var pos = document;
- while (pos.lastChild.nodeType == 1) pos = pos.lastChild;
Could document.write be redefined if in an xhtml document to parse into a tree and append?
Posted by Dion Almaer at 7:37 am