Wednesday, 2 October 2013

Load External Javascript + DOM elements

Load External Javascript + DOM elements

Im creating a external popup/dialog system for websites. Where on the
client side will include a javascript file from our system. And then the
javascript will create two DOM elements, one with the popup and one with a
black overlay.
Trying to do this async, but seams not too work.
<script type="text/javascript">
var smarrtalk = document.createElement('script');
smarrtalk.onload = function() {
init_smarttalk({ key: 'xxxxxxx' });
};
smarrtalk.src = "http://xxxx.js";
document.getElementsByTagName('head')[0].appendChild(smarrtalk);
</script>
Here is some snipptes from the code where the DOM elements +
init_smarttalk() function is called.
http://pastebin.com/4C5LF7mD

No comments:

Post a Comment