so I have an external javascript file, lets call it something.js and i document.write it to the document. For some reason, I cant access the function in Safari or FireFox.
It goes a little something like this:
<script type="text/javascript">
document.write(decodeURI("%3Cscript src='something.js' type='text/javascript'%3E%3C/script%3E"));
myFunction();
</script>
so this tells me myFunction is null, but if i put that same function call at the end of something.js, it works. Now this isnt the exact scenario, so I am aware that for this particualr case, this is not the best way to go about it.
Here’s how I do it:
Really, this makes sense only at page load time. If you are repeatedly downloading script in a dynamic fashion, you probably want to take a different approach, namely JSONP.