I can't get following problem. I define variables like this:
<script type="text/javascript">var myVar;</script>
<script type="text/javascript" src="/myScript.js"></script>
myScript.js looks something like this:
$(document).ready(function() {
myVar = new myClass();
myVar.init();
});
if I try to access the variable like this:
<div onclick="myVar.activate(x);">some content</div>
all is working fine, but if I do
<img src="path" onload="myVar.activate(x);"/>
I get an error "myVar is not defined". I don't get it.
<script type="text/javascript">var myVar;</script>
some DOM Elements
<script type="text/javascript" src="/myScript.js"></script>
<script type="text/javascript">myVar.activate(x);</script>
Is not working either?!?!! Weird, isn't it?
*x is generated serverside *