Ciao a tutti, sto sperimentando da pochi giorni il linguaggio javascript e mi sono imbattuto in questo problema:
praticamente, l'esecuzione dello script si blocca dopo aver stampato "PRIMA 0".
Vi posto il codice di tutti e 3 i file.
index.html
	
	
	
		
file1.js
	
	
	
		
file2.js
	
	
	
		
				
			praticamente, l'esecuzione dello script si blocca dopo aver stampato "PRIMA 0".
Vi posto il codice di tutti e 3 i file.
index.html
		HTML:
	
	<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Documento senza titolo</title>
<script type="application/javascript" language="javascript" src="file2.js"></script>
<script type="application/javascript" language="javascript" src="file1.js"></script>
</head>
<body>
<a href="javascript:void(0);" id="link" onclick="main()">click</a>
</body>
</html>
	file1.js
		Codice:
	
	var main = function()
{   
	alert('PRIMA ' + channelsArray.length);
	make_array(4);
	alert('DOPO ' + channelsArray.length);	
}
	file2.js
		Codice:
	
	var channelsArray = new Array();
var numero =  function()
{
    this.num1 = "";
    this.num2 = "";
	this.num3 = "";
	
	this.set_num1 = function(num1)
    {
        this.num1 = num1;
    }
	this.set_num2 = function(num2)
    {
        this.num2 = num2;
    }
	this.set_num3 = function(num3)
    {
        this.num3 = num3;
    }
}
var make_array =  function(num)
{
	var i;
	
	if(channelsArray != null)
		channelsArray = new Array();
	
	for(i=0; i<num; i++)
		array_values();
}
var array_values = function()
{
	var numero = null;
	
	numero = new numero();
	
	numero.set_num1(Math.floor((Math.random()*1000)+1));
	numero.set_num2(Math.floor((Math.random()*100)+1));
	numero.set_num3(Math.floor((Math.random()*10)+1));
	
	channelsArray.push(numero);
}