I think it's also worth noting that the document.write call in the current script also prevents any containing page from being delivered as application/xhtml+xml.
I also modified the code to use the script's "src" attribute to get a reference to it's parent container and then used appendChild in place of the document.write call. Not the most elegent solution but it shows that there are a number of alternatives to document.write in this case. On Mar 19, 9:36 pm, BuffLaser2000 <[email protected]> wrote: > In this code:http://twitter.com/javascripts/widgets/widget.js > > You are using document.write() to create the widget element. Bad bad > bad. Any AJAX site that tries to init the widget after the page loads > will have the entire page overwritten by the widget. > > W3C even has this to say about document.write(): > "Note: Try to avoid using document.write() in real life JavaScript > code. The entire HTML page will be overwritten if document.write() is > used inside a function, or after the page is loaded. However, > document.write() is an easy way to demonstrate JavaScript output in a > tutorial." > > So, I downloaded the JS file and modified TWTR.Widget to take a > container element name as part of the options object. If > set, .innerHTML is used on the container element instead of > document.write. > > This simple fix will make your widgets compatible with Web 2.0 sites. > > Thanks for listening. -- Twitter developer documentation and resources: http://dev.twitter.com/doc API updates via Twitter: http://twitter.com/twitterapi Issues/Enhancements Tracker: http://code.google.com/p/twitter-api/issues/list Change your membership to this group: http://groups.google.com/group/twitter-development-talk
