I'm developing a javascript widget, and I need to send parameters to Javascript, or be able to access variables defined within SCRIPT tag of an HTML. For example, Google Analytics. The GA code below makes variables like _setAccount and _trackPageview available to the javascript, and I need to do the same. How can I achieve that? How can the called javascript https://ssl.google-analytics.com/ga.js or http://www.google-analytics.com/ga.js in this case access the defined variables?
<script type="text/javascript">
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-XXXXXX-1']);
_gaq.push(['_trackPageview']);
(function() {
var ga = document.createElement('script');
ga.type = 'text/javascript';
ga.async = true;
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
var s = document.getElementsByTagName('script')[0];
s.parentNode.insertBefore(ga, s);
})();
</script>
Any help is highly appreciated.
TIA, James.
eval
is enough. – Blindy