Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Netscape crash while writing to multiple layers

Status
Not open for further replies.

Raver1

Programmer
Feb 21, 2002
11
NL
Can anyone help me with the following problem:

I'm trying to write new content to multiple layers from one function like this:

function writeContent(layerArray, contentArray) {
for(var i=0;i<layerArray.length;i++) {
//alert('Writing new content');
layerArray.document.open('text/html', 'replace');
layerArray.document.write(contentArray);
layerArray.document.close();
}
}


If I run this function Netscape will crash almost every time. However, when I uncomment the 'alert' in the code, it will almost never crash.
It seams like Netscape needs some time to catch it's breath before being able to write new content again.

By the way, the layerArray is an array I've created by using:
layerArray[x] = new Layer(100);

Does anyone have the same problem, or know a solution to this problem?

Thanx,

Raver1
 
Here's a tip: enclose all code in [ignore]
Code:
[/ignore] tags. This way, when you come across an element in an Array defined by [ignore][i][/ignore], it will not become italisized.


And by the way... Would you mind posting your entire code? [center][img]http://uniment.netfirms.com/bluebrain.gif[/img]  [img]http://uniment.netfirms.com/blueuniment.gif[/img][/center]
 
Hi UNIMENT,

This wouldn't quite fix my problem, because I'm trying to write HTML content to the layers.
I saw I made a little mistake:

for(var i=0;i<layerArray.length;i++) {
//alert('Writing new content');
layerArray.document.open('text/html', 'replace');
layerArray.document.write(contentArray);
layerArray.document.close();
}


should have been (forum-software replaced the [ i ] with italic):

for(var j=0;j<layerArray.length;j++) {
//alert('Writing new content');
layerArray[j].document.open('text/html', 'replace');
layerArray[j].document.write(contentArray[j]);
layerArray[j].document.close();
}


I've found that the second time I write new HTML content to the layers, Netscape crashes. The first time everything is OK.

On your question to post the complete source; it's pretty difficult to do, because it's over 3.000 lines of code.

Greetzzz...

Raver1
 
Yes... the forum software is supposed to make text enclosed in [ignore][/ignore] italic.

But about the code... the code I tested (see below) worked fine... Do you have a site on which you have a demonstration of code that will crash NS?


Code:
<layer name=&quot;myLayer&quot; onmouseover=&quot;alert(this.document)&quot;>bah</layer>
<script type=&quot;text/javascript&quot;>
<!--
a=document.layers.myLayer.document;
setTimeout('a.open(&quot;text/html&quot;,&quot;replace&quot;);a.write(&quot;STUPID&quot;);a.close()',0);
setTimeout(&quot;a.open('text/html','replace');a.write('AHH'); a.close();&quot;,999);
setTimeout(&quot;a.open('text/html','replace');a.write('hahahaah'); a.close();&quot;,1999);
// -->
</script>
bluebrain.gif
blueuniment.gif
 
Hi UNIMENT,

Nope, the site isn't live yet. We're still developing it.

My guess is, that your code will work just fine, but my code is a little different. I use an Array of Layers, and write to their documents from one function.
Also I can't use the '<LAYER>' tag, so I use 'new Layer(10);' to dynamicaly create Layers.

The problem doesn't seem to occur when I write to just one Layer's document, but when I write to multiple layers from within one function-call, I get the crash.

Greetzzz...

Raver1
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top