By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
437,712 Members | 2,174 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 437,712 IT Pros & Developers. It's quick & easy.

Multiple loops

P: n/a
Hi all,

I'm my script I've three loops processing a very huge data file. IE &
Firefox show a message box after some time saying my script could be
infinite looping and give me a chance to stop it.

Is there a way to prevent this dialog box to show up? I'm writing a
script used only on a intranet and the final customer should not see the
message box.

Thanks in advance,
Feb 6 '06 #1
Share this Question
Share on Google+
6 Replies


P: n/a
Fabian Vilers wrote on 06 feb 2006 in comp.lang.javascript:
I'm my script I've three loops processing a very huge data file. IE &
Firefox show a message box after some time saying my script could be
infinite looping and give me a chance to stop it.

Is there a way to prevent this dialog box to show up? I'm writing a
script used only on a intranet and the final customer should not see the
message box.


Consider not using clientside scripting.

--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
Feb 6 '06 #2

P: n/a
Evertjan. wrote:
Consider not using clientside scripting.


Unfortunately, this is not an option.
Feb 6 '06 #3

P: n/a
Fabian Vilers wrote on 06 feb 2006 in comp.lang.javascript:
Evertjan. wrote:
Consider not using clientside scripting.


Unfortunately, this is not an option.


A programmer without technically necessary options
should decline the assignment!

In-browser javascript is not fitted for huge tasks.
[due to time and memory constraints]

Try:

A good database, w/cscript, compiled tasks like VB, c++, etc.

--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
Feb 6 '06 #4

P: n/a
Evertjan. wrote:
A programmer without technically necessary options
should decline the assignment!

In-browser javascript is not fitted for huge tasks.
[due to time and memory constraints]

Try:

A good database, w/cscript, compiled tasks like VB, c++, etc.


Thanks for your analysis Evertjan ;-) Like I said, I've no option. My
best choice for now on is to make big replace in a string :( (see other
post).

Thanks anyway
Feb 6 '06 #5

P: n/a
Fabian Vilers wrote:
I'm my script I've three loops processing a very huge data file. IE &
Firefox show a message box after some time saying my script could be
infinite looping and give me a chance to stop it.

Is there a way to prevent this dialog box to show up? I'm writing a
script used only on a intranet and the final customer should not see
the message box.


Since as you say not only using client-side scripting is not an option, I
think with unchanged code (see below) you will have to restrict your target
browser to Firefox and have your clients set this preference in their
user.js configuration file (or via `about:config'):

user_pref("dom.max_script_run_time", "0");

Setting this preference to 0 is specified to disable the warning. I have
set it to 60 (seconds) here.

I do not know if there is such a preference for IE, hence the Firefox
restriction.

However, you should definitely analyze the efficiency of your code,
especially of your loops, before you try anything else. For example,
using

/* a is an Array or collection object */
// order does not matter
for (var i = a.length; i--;)

or

// order does matter
for (var i = 0, len = a.length; i < len; i++)

is known to be faster than

for (var i = 0; i < a.length; i++)

Storing references of lookups from to the second level upwards in a (local)
variable and reusing that variable instead of looking up over and over
again (as was done in the first two examples) is another working means to
increase runtime efficiency, thus decreasing runtime.
HTH

PointedEars
Feb 6 '06 #6

P: n/a
Thomas 'PointedEars' Lahn wrote:
Fabian Vilers wrote:
["script too slow" warning in IE and Firefox]


Since as you say not only using client-side scripting is not an option, I
think with unchanged code (see below) you will have to restrict your
target browser to Firefox and have your clients set this preference in
their user.js configuration file (or via `about:config'):

user_pref("dom.max_script_run_time", "0");


Should be

user_pref("dom.max_script_run_time", 0);

of course.
PointedEars
Feb 6 '06 #7

This discussion thread is closed

Replies have been disabled for this discussion.