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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

rewriting to layers in NS

Status
Not open for further replies.

gnet

Programmer
May 3, 2002
21
US
hi all, i'm stumped by this problem in netscape and i need some help. here is the problem:

there are two absolute layers on the page, A and B, with the same offsets. i write to layer A and then to layer B. now i want to clear all the content i wrote to layer A and write something else there. writing to layer A again simply overwrites the content there, but i want to *replace* the old content instead of writing on top of it. how do i do this?

thanks in advance,
gnet
 
In Netscape if you write something to the layer the previous content is gone.So If you need to get the previous content and process it, there is one solution.

Before writing anything buffer it to a javascript variable and write your data next time before writing you have them in a string now you can process and add some thing to it.
eg:

<script>
var contentA = &quot;&quot;;
var contentB = &quot;&quot;;
function writeToLayer(id,content){
var layerdoc = document.layers[id].document;
layerdoc.open();
//process contentA
contentA += content;
layerdoc.write(contentA);
layerdoc.close();
}
</script>

So using the above code you dont replace the content you incrementally add to it. As far as i know this is the only solution known to me since Netscape doesnt support the innerHTML property.
 
hi rajeessh, thanks for the reply. the problem i'm having is actually the opposite of what you wrote: by default netscape is concatenating data when i rewrite to the layer because i have not yet used document.close(), but what i want is to flush out that layer and write out entirely new content. the saving to variable method did not work for me because i'm writing too much data and netscape freezes up when all that data is concatenated to the variable, that's why i have to rely on document.write() only. to see what i'm talking about see if you can do this:

1. create two absolute layers, A and B
2. write something to layer A
3. write something to layer B
4. erase all content in layer B and write something else there
5. erase all content in layer A and write something else there

what you'll see is that when you perform step 5, layer A just disappears. that is my problem in a nutshell.

gnet
 
well i finally got it to work, and it just proves how crazy netscape is. solution:

you need to create layers using <LAYER ID=blah ...></LAYER> instead of something like <SPAN ID=blah STYLE=position:absolute...>.

weird huh.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top