Hi there!
I'm having a problem with javascript only when I run them in separate .js files, and not when I'm using raw script in my HTML.
Here is a short exemple of what will work:
code:
<html>
<head>
<title></title>
</head>
<body>
<script>
var A = {
Function : function()
{
if(B)
alert(B);
else
alert('B NOT FOUND');
}
}
A.Function();
var B = {}
</script>
</body>
</html>
Now I want to run the same A.Function() call, but I need to move A and B singletones objects definition in separate js file, I got something like this:
code:
<html>
<head>
<title></title>
</head>
<body>
<script src="test1.js"></script>
<script src="test2.js"></script>
<script>
A.Function();
</script>
</body>
</html>
where test1.js and test2.js contains respectively declaration for A and B singletones, that still work because both objects are declared, now remove the js file that contain B and you will obtain 'B' is undefined error wich is sad because I was just checking B existence in my A code.
So if anyone have a solution to solve this issue nicely (I need to use separate js files for my singletones objects declarations), I would be very glad to hear it!
Thanks a billion.
Gauthier