Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Web Programming > JavaScript > Javascript
|
Javascript General Javascript discussions.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Javascript section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old October 7th, 2004, 01:38 PM
Authorized User
 
Join Date: Aug 2003
Posts: 54
Thanks: 0
Thanked 0 Times in 0 Posts
Default Script causes IE to run slowly

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>
 
Old October 7th, 2004, 05:39 PM
Friend of Wrox
 
Join Date: Nov 2003
Posts: 1,285
Thanks: 0
Thanked 2 Times in 2 Posts
Default

There is no way to avoid this error.

http://support.microsoft.com/?kbid=175500

Sorry!

-Snib <><
http://www.snibworks.com
There are only two stupid questions: the one you don't ask, and the one you ask more than once ;)





Similar Threads
Thread Thread Starter Forum Replies Last Post
cant run my script! angelic_scars Beginning PHP 1 November 9th, 2006 12:17 AM
how do i make a script run in background LIMONADA VBScript 6 April 25th, 2006 11:21 AM
run asp script from aspx PostmanPat C# 3 September 14th, 2004 12:58 PM
Run Script via Forms 6i bilal Oracle 0 August 12th, 2003 11:47 PM
Call and run CGI script from a PHP script ... how? dbruins BOOK: Beginning PHP4/PHP 5 ISBN: 978-0-7645-4364-7; v5 ISBN: 978-0-7645-5783-5 1 June 10th, 2003 03:09 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.