View Full Version : Changing text in one frame from another frame.

08-31-2007, 03:46 AM

I want to "rotate" (change) the text in some frames without reloading the pages.

To do this I have created a "control" frame that will reload and then change the text, but I can't get it to work.

Code for visible frame "adframe":

<html><body background='./images/backgrounds/marble.jpg'>
<div id="ads"></div>

Code for "control" frame:

<script language="JavaScript"><!--
top.adframe.document.getElementById('ads').innerHTML="Buy My Stuff!";

it says "Error: 'top.adframe.document.getElementById(...)' is null or not an object"

It worked when I used top.adframe.document.write("Buy My Stuff!"), but it just added the line over an over, it didn't replace it.

What am I doing wrong?

08-31-2007, 02:58 PM
Maybe you're not letting adframe load first? For your control frame,do

top.onload = function () {
top.adframe.document.getElementById('ads').innerHTML="Buy My Stuff!";

09-03-2007, 05:02 PM
Thank you. I will try that tomorrow.

But I think I read something about how you can't use the innerHTML function with a frame. Is that true?