I have a page where I want to demo some web widgets. When user clicks a "Add widget" button, I want to dynamically add the widget he/she selects on the same page in a blank DIV. For example, following is the code for an Addthis button. I tried to add this to the DOM using javascript. I tried both innerHTML and document.write() and neither works. The tags end up in the DOM but the javascript code where the src points to never get executed.
<div class="addthis_toolbox addthis_default_style">
<a href="http://www.addthis.com/bookmark.php?v=250&amp;username=xa-4cac9ad61a93c252" class="addthis_button_compact">Share</a>
</div>
<script type="text/javascript" src="http://s7.addthis.com/js/250/addthis_widget.js#username=xa-4cac9ad61a93c252"></script>
How can I get the dynamically added javascript to execute or if this is not possible? Please help. Thanks.