Closed Thread Icon

Preserved Topic: dynamically writing to layers Pages that link to <a href="https://ozoneasylum.com/backlink?for=18260" title="Pages that link to Preserved Topic: dynamically writing to layers" rel="nofollow" >Preserved Topic: dynamically writing to layers\

 
Author Thread
anomaly
Nervous Wreck (II) Inmate

From:
Insane since: May 2002

posted posted 05-12-2002 05:56

hi, still new to dhtml. was wondering if it's possible to dynamically write content to a layer. i know you can do that to the body text with the document.write() function. how can i do that for a predefined layer? or should i just make multiple layers with the text already written and just toggle the visibility?

anomaly
Nervous Wreck (II) Inmate

From:
Insane since: May 2002

posted posted 05-12-2002 06:23

i think i found something. do i use innerHTML somehow?

bitdamaged
Maniac (V) Mad Scientist

From: 100101010011 <-- right about here
Insane since: Mar 2000

posted posted 05-12-2002 06:53

In IE and DOM compliant browsers it's layername.innerHTML = "your text/HTML here";

I can't remember off the top of my head the NN 4.* version of this.



.:[ The Tao of Steve ]:.
Be Desireless
Be Excellent
Be Gone
...................................

mr.maX
Maniac (V) Mad Scientist

From: Belgrade, Serbia
Insane since: Sep 2000

posted posted 05-12-2002 12:51

In Internet Explorer 4+:
document.all["nameoflayer"].innerHTML = "layer content";

In Netscape 4+:
document.layers["nameoflayer"].document.open();
document.layers["nameoflayer"].document.write("layer content");
document.layers["nameoflayer"].document.close();

In DOM compatible browser (IE5, Mozilla):
document.getElementById("nameoflayer").innerHTML = "layer content";

BTW Opera doesn't support dynamic layer content change.


anomaly
Nervous Wreck (II) Inmate

From:
Insane since: May 2002

posted posted 05-17-2002 08:10

hey thanks a lot. this loads way faster than rollover images. yay dhtml

hyperbole
Paranoid (IV) Inmate

From: Madison, Indiana, USA
Insane since: Aug 2000

posted posted 05-20-2002 16:18

How do you change the background image for a layer in the various browsers?

CPrompt
Maniac (V) Inmate

From: there...no..there.....
Insane since: May 2001

posted posted 05-20-2002 16:52

hyperbole:
check out these pages listed here: http://www.ozoneasylum.com/Forum2/HTML/001569.html

You can make the background image in different layers change using these techniques.
Just put the background image in the layer that you want and change it for each style sheet and that will do it.

U-Neek used something like this as well as Sash.

Later,
C:\


~Binary is best~

Slime
Lunatic (VI) Mad Scientist

From: Massachusetts, USA
Insane since: Mar 2000

posted posted 05-20-2002 17:44

I'm sure cprompt answered your question, but to answer it more directly:

document.getElementById('theElementsId').style.background = 'url(newbgimg.jpg) #430404';
// (the color will appear if the background image fails to load)

Of course, to set this in NN4 or IE 4 you'll need to use document.theElementsId and document.all.theElementsId, respectively. I wouldn't be surprised if it doesn't work in NN4.

anomaly
Nervous Wreck (II) Inmate

From:
Insane since: May 2002

posted posted 05-31-2002 09:42

thanks for all the help. i got everything working fine in IE and i just got a chance to run it in netscape 4.7. of course, i ran into some odd problems. i used mr. max's procedure for handling netscape. the text is dynamically changing (a good sign), but the text is not being confined to the boundaries of my <div>. In IE, it automatically textwraps at the edge of the layer and in netscape, just runs on. i'm thinking it is a css problem, but i'm not sure where. in case you're wondering, i'm using this to change the text in a thought bubble over a picture. the text just runs off the background bubble in netscape. perhaps i should just be thankful something is working in N4...or should i just give up on netscape 4 altogether?

mr.maX
Maniac (V) Mad Scientist

From: Belgrade, Serbia
Insane since: Sep 2000

posted posted 05-31-2002 20:12

I think that you're right, the problem is probably related to CSS...


« BackwardsOnwards »

Show Forum Drop Down Menu