Help! I keep getting the following message box when I run my script:
âA script on this page is causing Internet Explorer to run slowly. If it continues to run, your computer may become unresponsive.
Do you want to abort the script?â
The script involves two arrays. The first array is contained in an external .
js file and includes roughly 43,000 elements (Iâll call this Array1). Each element is a 9-digit number.
The second array (Iâll call this Array2) is built by comparing each element in Array1 with a pre-selected 9-digit number (Iâll call the Base Number)as well as with the rest of the elements that may have been added to Array2.
The script begins by using the Base Number to set the first element of Array2. It then cycles through and compares each element in Array1 with element in Array2 based on pre-selected criteria.
If the criteria are met, the number from Array1 is added to Array2, and then the next element in Array1 is compared.
While I expected that the procedure would take some time to run, I did not expect the message box.
Any suggestions?
Following is the code:
Code:
<script language=JavaScript src="GM10Ign.js"></script>
<script language=JavaScript>
var gmArray1= new Array;
function checkCodes()
{
var number_1;
var number_2;
var reference="";
var fnlArray = "";
number_1 = "133131132";
gmArray1[0]= number_1;
for(var index1 = 0; index1 < GM10Ign.length; index1++)
{
number_2 = GM10Ign[index1];
var numPass = accNumber(number_2);
if(numPass == 1)
{
gmArray1[gmArray1.length]=number_2;
}
}
writeArray();
return false;
}
function accNumber(number2)
{
var MCD = 2;
var reqNum = 3;
var number_3;
var difference;
for(var index2 = 0; index2 < gmArray1.length; index2++)
{
var totNum = 0;
var noPass = 1;
number_3 = gmArray1[index2].toString();
for(var i = 0; i < number_3.length; i++)
{
difference = number2.charAt(i) - number_3.charAt(i);
if(Math.abs(difference)>= MCD)
{
totNum = totNum + 1;
}
}
if(totNum < reqNum)
{
noPass = 0;
}
}
return noPass;
}
function writeArray()
{
var fnlBitting = "";
for(var i = 0; i < gmArray1.length; i++)
{
fnlBitting+= gmArray1[i] + "<br>";
}
document.write(fnlBitting);
return false;
}
</script>
</head>
<body bgcolor="#FFFFFF" text="#000000" link="#0000FF" vlink="#800080" alink="#FF0000">
<h1></h1>
<input type="button" value="press" onclick="return checkCodes()">
<p>Created on ... October 07, 2004</p>
</body>