473,671 Members | 2,370 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

small script --> huge load --> error message

Ok, I'm sure everybody who works with javascript has seen this
or similar messages depending on their agent:

A script on this page is causing mozilla to run slowly.
If it continues to run, your computer may become unresponsive.
Do you want to abort the script?
[ OK ] [Cancel]

besides the very confusing OK/Cancel buttons in FireFox, is there a
way to tell a javascript to give control back to the agent interface
for a few moments?

I am trying to list "all" the characters in tables (from #x0000-#xffff)
yeah, that's 65K characters...

the function is defined in the <head> section and goes:

<script type="text/javascript">

function createlist()
{
var hex="0123456789 abcdef";
hex=hex.split(" ");
var fourth, third, second, first, spezial;
var oBody=document. getElementsByTa gName("body").i tem(0);
var oTable, oTHead, oTBody, oTFoot, oCaption;
var oRow, oCell, oHell, oDiv;

for (first=0;first< =15;first++)
{
for (second=0;secon d<=15;second++ )
{
oTable = document.create Element("table" );
oTHead = document.create Element("thead" );
oTBody = document.create Element("tbody" );
oTFoot = document.create Element("tfoot" );
oCaption = document.create Element("captio n");

oTable.appendCh ild(oCaption);
oTable.appendCh ild(oTHead);
oTable.appendCh ild(oTBody);
oTable.appendCh ild(oTFoot);
oTable.border=1 ;

oRow=document.c reateElement("t r");
oTHead.appendCh ild(oRow);
oCell = document.create Element("th");
oCell.appendChi ld(document.cre ateTextNode("He x"));
oRow.appendChil d(oCell);
oBody.appendChi ld(oTable);
for (oHell=0;oHell< 16;oHell++){
oCell = document.create Element("th");
oCell.appendChi ld(document.cre ateTextNode(hex[oHell]));
oRow.appendChil d(oCell);
}
oTBody = document.create Element("tbody" );
oTable.appendCh ild(oTBody);

for (third=0;third< =15;third++)
{
oRow=document.c reateElement("t r");
oTBody.appendCh ild(oRow);
oCell=document. createElement(" td");
oCell.appendChi ld(document.cre ateTextNode("&# x"+hex[first]+hex[second]+"n"+hex[third]+";"));
oRow.appendChil d(oCell);
for (fourth=0;fourt h<=15;fourth++ )
{
oCell=document. createElement(" td");
oCell.innerHTML ="&#x"+hex[first]+hex[second]+hex[fourth]+hex[third]+";";
oRow.appendChil d(oCell);
}
}
}
}
}

</script>
and then in the body I call

<script type="text/javascript">
createlist();
</script>

plain and simple, well, except for the load it creates iterating through 16^4
characters creating 16^2 tables and 16^4+16^2 cells and 16^3+16^2 rows
(rough calculations off the top of my head ;-)

Is there a way to diffuse the load and still getting all the tables created?
Aug 30 '05 #1
3 1557
Robi wrote:
Ok, I'm sure everybody who works with javascript has seen this
or similar messages depending on their agent:

A script on this page is causing mozilla to run slowly.
If it continues to run, your computer may become unresponsive.
Do you want to abort the script?
[ OK ] [Cancel]

besides the very confusing OK/Cancel buttons in FireFox, is there a
way to tell a javascript to give control back to the agent interface
for a few moments?
You may find this enlightening (and sympathetic too):

<URL:http://www.fourmilab.c h/fourmilog/archives/2005-08/000568.html>

The short answer is:

1. Type "about:conf ig" in the address bar

2. Scroll down to "dom.max_script _run_time"

3. Double-click it and set it to however many seconds you'd like Firefox
to wait before presenting the confirm dialog.

I am trying to list "all" the characters in tables (from #x0000-#xffff)
yeah, that's 65K characters...

the function is defined in the <head> section and goes:

<script type="text/javascript">


Using DOM is commendable, but for this task I think you will find that
good 'ol non-standard 'DOM 0' document.write is hugely faster.

Excuse me for not testing it! I'll have a go and post back later...

[...]

--
Rob
Aug 30 '05 #2
RobG wrote:
Robi wrote:
Ok, I'm sure everybody who works with javascript has seen this
or similar messages depending on their agent:

A script on this page is causing mozilla to run slowly.
If it continues to run, your computer may become unresponsive.
Do you want to abort the script?
[ OK ] [Cancel]

besides the very confusing OK/Cancel buttons in FireFox, is there a
way to tell a javascript to give control back to the agent interface
for a few moments?

You may find this enlightening (and sympathetic too):

<URL:http://www.fourmilab.c h/fourmilog/archives/2005-08/000568.html>

The short answer is:

1. Type "about:conf ig" in the address bar

2. Scroll down to "dom.max_script _run_time"

3. Double-click it and set it to however many seconds you'd like Firefox
to wait before presenting the confirm dialog.

I am trying to list "all" the characters in tables (from #x0000-#xffff)
yeah, that's 65K characters...

the function is defined in the <head> section and goes:

<script type="text/javascript">

Using DOM is commendable, but for this task I think you will find that
good 'ol non-standard 'DOM 0' document.write is hugely faster.

Excuse me for not testing it! I'll have a go and post back later...


Try this one:
- closing tags for tr & td omitted
- unused head, foot and caption elements omitted
- unneccessary (in this case) tbody omitted
function createlist() {
var hex="0123456789 abcdef";
hex=hex.split(" ");
var n = hex.length;
var fourth, third, second, first, spezial;
var oBody = document.body;
var txt=[];

for ( first=0; first<n; first++ ) {
for (second=0;secon d<n;second++) {
txt.push('<tabl e border="1"><tr> <th>Hex<');

for ( oHell=0; oHell<n; oHell++){
txt.push('<th>' + hex[oHell]);
}

for ( third=0; third<n; third++) {
txt.push('<tr>< td>' + '&#x' + hex[first]
+ hex[second] + 'n' + hex[third] + ';');

for ( fourth=0; fourth<n; fourth++) {
txt.push('<td>' + '&#x' + hex[first]
+ hex[second] + hex[fourth] + hex[third] + ';');
}
}
txt.push('</table>');
}
}
document.write( txt.join(''));
}
--
Rob
Aug 30 '05 #3
RobG wrote:
RobG wrote:
Robi wrote:
Ok, I'm sure everybody who works with javascript has seen this
or similar messages depending on their agent:

A script on this page is causing mozilla to run slowly.
If it continues to run, your computer may become unresponsive.
Do you want to abort the script?
[ OK ] [Cancel]

besides the very confusing OK/Cancel buttons in FireFox, is there a
way to tell a javascript to give control back to the agent interface
for a few moments?
You may find this enlightening (and sympathetic too):

<URL:http://www.fourmilab.c h/fourmilog/archives/2005-08/000568.html>

I did run across this page while trying to figure out what I could do,
but decided it to be a "hack" approach and try a different way because
if someone else wants to use the script (as perversely as it sounds)
that or those someones would need to adjust their agents and that wouldn't
necessarily have to be FF alone, and since I didn't find any "other"
obvious possibility I decided to post my question here.

[...] Using DOM is commendable, but for this task I think you will find that
good 'ol non-standard 'DOM 0' document.write is hugely faster.

Excuse me for not testing it! I'll have a go and post back later...


Try this one:
- closing tags for tr & td omitted
- unused head, foot and caption elements omitted
- unneccessary (in this case) tbody omitted


I understand the last two :-) but I didn't know tr/th/td end tags were optional until now
(probably until I or someone else change the document to xhtml...)

cool, thanks, now that's slim jim ;-)
function createlist() {
var hex="0123456789 abcdef";
hex=hex.split(" ");
var n = hex.length;
var fourth, third, second, first, spezial;
var oBody = document.body;
var txt=[];

for ( first=0; first<n; first++ ) {
for (second=0;secon d<n;second++) {
txt.push('<tabl e border="1"><tr> <th>Hex<');

for ( oHell=0; oHell<n; oHell++){
txt.push('<th>' + hex[oHell]);
}

for ( third=0; third<n; third++) {
txt.push('<tr>< td>' + '&#x' + hex[first]
+ hex[second] + 'n' + hex[third] + ';');

for ( fourth=0; fourth<n; fourth++) {
txt.push('<td>' + '&#x' + hex[first]
+ hex[second] + hex[fourth] + hex[third] + ';');
}
}
txt.push('</table>');
}
}
document.write( txt.join(''));
}


and the message didn't appear! :-D
oh, I tried to make "smaller" write() "blocks", moving the document.write( )
into the "for(first" block, in the hope I would see the page grow, but all
I got was the message again, so I scraped that.
Thinking about it now, and after having read the fourmilab.ch article, it's
clearer to me, because wanting to run the script /and/ wanting to display
the data as it grows, uses all of FFs graphical/script resources.

Rob, thanks alot for the tip with the write('html')
instead of DOM createElement. Works great!

--
Robi
Aug 30 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
1289
by: trdonavan | last post by:
Several things may have happened since I last successfully debugged this project. Something has caused it to fail to debug giving the message: Parser Error Message: Could not load type '<project>.Global' I have read many posts on this message until I came to understand that something is a bit different in my case. The <project>.dll exists and is getting compiled.
11
3121
by: Wolfgang Kaml | last post by:
I am not sure if this is more of an expert question, but I am sure that they are out there. I'd like to setup a general application or bin directory on my Win2003.Net Server that will hold some useful utils that more pages on that server can use. As an example, I have created a Page Counter class that opens an Access .mdb file, counts the current entries for that page, and adds a new entry with some information regarding the current...
0
996
by: Michael Brame | last post by:
Hello, I am getting the "Provider Load Failure" error message when attempting to install FMStocks 7. I have seen other people post with this error but have not seen a solution for it yet. I have tried it on several Windows Server 2003 boxes as well as XP boxes and still cannot get around it. Any help would be greatly appreciated.
1
1203
by: sling blade | last post by:
Hi, For some reason asp.net will not let me publish a new Webpage. I am able to create a new page however when I set it as the start page and hit run, I recieve "Could not load type" error message. The first line of the html is highlighted. I have tried to create a second page with the same results. The second page was blank I had not written any code for it.
0
1011
by: Curtiss | last post by:
I receive "could not load type" error message when trying to load aspx page. The DLL is built and is located in the correct bin directory. The type name in the "inherits" attribute matches the type name in the DLL. The permissions on the bin drectory look okay. In fact, the problem only occurs on a small number of machines. I have been unable to find any differences between the good and bad machines as far as software versions and...
1
1481
by: Rob R. Ainscough | last post by:
Can someone tell me how to debug a Windows Install problem? I've created the installer project from home PC, transfered the installer project to my work PC, build the project on my work PC, but now when I run the Setup.exe it immediate generates a small dialog box with the following: <Error Message> Only option is to press Ok button which brings me to my Installation Incomplete dialog where Close is the only option.
8
2846
by: Taras_96 | last post by:
Hi everyone, We' ve come to the conclusion that we wish the user to be directed to an error page if javascript is disabled <enter comment about how a webpage shouldn't rely on javascript here :) >. I've read quite a few posts on how to do this, but none meet my need (the two main suggestions was set a jsEnabled variable in a <scriptsection of the HTML and read it in PHP, and the other suggestion was by default loading the non js page,...
4
3024
by: rukkie | last post by:
Hi, I have some problems with a PHP reference in a <SCRIPTtag, but only with the Internet Explorer, which gives a "Error on page" message in the Status Bar. The code is as follows : <script> <!-- var stat =<?php echo stripslashes($status); ?>; window.status = stat;
2
3495
by: Jonathan Crawford | last post by:
Hi I made a small change to a .Net 2 framework website and uploaded it today and went to the site and got Parser Error Message: Could not load type 'Tgsi.CortijoRomero.Website.Global'. Source Error: Line 1: <%@ Application Codebehind="Global.asax.vb" Inherits="Tgsi.CortijoRomero.Website.Global" %>
0
8472
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8390
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
1
8596
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8667
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
6222
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5690
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4399
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
2048
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1801
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.