written by craig, 12 July 2007
The AutoDirector widget code is something like:
A brilliant article at SitePoint describes the issues and a solution that’s so obvious, I’m not aware of anyone using it before!
In effect, it proposes that you identify the calling <script> element, then use it as a reference in an insertBefore to inject HTML nodes into the DOM. It’s simple, effective, and clean. It means that the AutoDirector showroom widget code can be even shorter and avoid innerHTML as well as document.write.