How can I reach some variable declared in another place from within an external javascript file ?
Suppose in an html file I have the following
<head>
<script>
var a = 'something';
</script>
<head>
<body>
<iframe src="otherfile.html"/>
</body>
and inside otherfile.html, in the section, I have
alert(a);
How can I make sure I get an alert message saying "something" ?
I think Google Adsense does this, their code is:
<script type="text/javascript"><!--
google_ad_client = "youdontneedtoknowthis";
google_ad_slot = "5404192644";
google_ad_width = 728;
google_ad_height = 90;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script>
How can the script in http://pagead2.googlesyndication.com/pagead/show_ads.js know those variables (e.g. google_ad_client) ?