Click to See Complete Forum and Search --> : Changing layer contents in another frame


el22
10-29-2003, 10:56 PM
I need to change the text that two layers or divs (i dont know if it would make a difference in this case to use a layer or div) have in another frame. That frame is like a header that shows a title and a subtitle.

I.e.: i have a page in the "main" frame that in the OnLoad event calls a function that should change the two layers' content in the other frame dynamically.

The current function I made is:function changeheadertext()
{
parent.header.document.getElementById(headertitle).innerHTML="titletext";
parent.header.document.getElementById(headersubtitle).innerHTML="subtitletext";
}

being "header" the frame name where the layers are and "headertitle" and "headersubtitle" the layers IDs.

However, (:P) its not working and i'm not sure how to change the contents of a layer in a different frame. Could you please give me a hand with this?

Thanks in advance for any help you could give me.

Mr J
10-30-2003, 06:54 AM
Please try the following, you missed out the quotes





function changeheadertext()
{
parent.header.document.getElementById("headertitle").innerHTML="titletext";
parent.header.document.getElementById("headersubtitle").innerHTML="subtitletext";
}

el22
10-30-2003, 03:12 PM
Thanks, but that didn't work either.

I tried with another code:

function changeContent(id,shtml) {
if (document.getElementById || document.all) {
var el = top.headerpg.document.getElementById? top.headerpg.document.getElementById(id): document.all[id];
if (el && typeof el.innerHTML != "undefined") el.innerHTML = shtml;
}
}

function changeheadertext()
{

changeContent("headertitle","Title Text");
changeContent("headersubtitle","Subtitle Text");

} The function called in OnLoad is changeheadertext().
"headerpg" is the frame where the layers are located.

This works perfectly in Mozilla Firebird 0.7, but in IE it gives a runtime error.

Any hint on why it doesn't work in IE 6?

Thanks again :)

Mr J
10-30-2003, 05:03 PM
See if this works

el22
10-30-2003, 05:29 PM
Originally posted by Mr J
See if this works Ok, I found the problem (weird problem by the way). IE doesn't like the <layer> tag apparently, and the code works now in IE if i use <div> instead. Mozilla has no problem with <layer> though. I finally find the difference between those two :eek: .

Thanks a lot Mr. J !

This is what I call quality support :D

Mr J
10-31-2003, 03:40 AM
Ah! the layer tag, now you didn't specifically say you were using the "LAYER" tag.

The "LAYER" tag is not an IE tag so it will not work in IE.

Always use a DIV tag

el22
10-31-2003, 12:05 PM
Originally posted by Mr J
Ah! the layer tag, now you didn't specifically say you were using the "LAYER" tag.

The "LAYER" tag is not an IE tag so it will not work in IE.

Always use a DIV tag Yeah, good to know. Thanks.

I always thought they were just the same.