473,385 Members | 1,753 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Updating text in a different frame with NN7

I have a simple frame-based application where title information
appears in a top frame and a lower frame contains the content
for the application. One of the needs for this app is for a
status line in the upper frame to be updated when certain
actions are taken in the lower frame.

In the top frame, I have a line of text wrapped with SPAN tags
and assigned a unique ID attribute.

In the lower frame, I run a JS function that looks up the ID
using the DOM (getElementById()) and then assigns the new
text to the innerText of that element. Under IE, this works
perfectly fine. Under NN7 the text in the upper frame doesn't
change (although it does appear that it is getting set).

Any ideas? A sample app appears below.

Thanks in advance,

Paul
[some minor clutter in the script below to ensure readability
and clean initialization]
[sample.html]

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<FRAMESET border="0" cols="*" rows="95,*,38">
<FRAME name="topframe" src="sample_top.html" noresize>
<frame name="sample_bottom" src="sample_bottom.html" noresize>
</FRAMESET>

[sample_top.html]
<frameset rows="*" cols = "125,*" frameborder="no" framespacing="0"
border="0">
<frame src="sample_topleft.html" scrolling="no" frameborder="no"
framespacing="0" border="0" noresize>
<frame name="titleframe" src="sample_topright.html" scrolling="no"
frameborder="no" framespacing="0" border="0" noresize>
</frameset>

[sample_topleft.html]
<body>
<h2>[Logo]</h2>
</body>

[sample_topright.html]
<script language="JavaScript">
var loaded = false;
</script>
<body onload="loaded = true;">
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td>
<h2>Some fixed text, graphics, whatever</h2>
</td>
</tr>
<tr><td><h4><span id="variable">This text should
vary</span></h4></td>
</tr>
</table>
[sample_bottom.html]
<body>
<script language="JavaScript">
var tries = 0;
var the_text = "None";

function set_variable(txt) {
if (txt) {
the_text = txt;
} else {
txt = the_text;
}

if (top.topframe && top.topframe.titleframe &&
top.topframe.titleframe.loaded) {
tries = 0;
_set_variable(txt)
} else if (tries < 5) {
tries++;
setTimeout("set_variable()", 1000);
} else {
alert("Failed to load top frame");
}
}

function _set_variable(txt) {
var doc = (top.topframe) ? top.topframe.titleframe.document : null;

if (doc.getElementById) {
elem = doc.getElementById('variable');
if (elem == null) {
alert("get by id: no element available");
}
} else if (doc.all) {
elem = doc.all("variable");
alert("get all");
} else {
alert("can't access element");
elem = null;
}

if (elem) {
elem.innerText = "Variable text: " + txt;
} else {
alert( "Can't access variable" );
}
}
</script>

<!-- various page contents here... -->

<script language="JavaScript">
set_variable("Follow");
</script>

<center>
<a href="sample_bottom2.html">Follow</a> Me
</center>

</body>
[sample_bottom2.html]
<body>
<script language="JavaScript">
var tries = 0;
var the_text = "None";

function set_variable(txt) {
if (txt) {
the_text = txt;
} else {
txt = the_text;
}

if (top.topframe && top.topframe.titleframe &&
top.topframe.titleframe.loaded) {
tries = 0;
_set_variable(txt)
} else if (tries < 5) {
tries++;
setTimeout("set_variable()", 1000);
} else {
alert("Failed to load top frame");
}
}

function _set_variable(txt) {
var doc = (top.topframe) ? top.topframe.titleframe.document : null;

if (doc.getElementById) {
elem = doc.getElementById('variable');
if (elem == null) {
alert("get by id: no element available");
}
} else if (doc.all) {
elem = doc.all("variable");
alert("get all");
} else {
alert("can't access element");
elem = null;
}

if (elem) {
elem.innerText = "Variable text: " + txt;
} else {
alert( "Can't access variable" );
}
}
</script>

<script language="JavaScript">
set_variable("Me");
</script>

<center>
Follow <a href="sample_bottom.html">Me</a>
</center>

</body>
[end-of-sample-app]
Jul 20 '05 #1
2 1765
: Any ideas? A sample app appears below.
Maybe:

Change [sample.html] to:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<FRAMESET border="0" cols="*" rows="95,*,38">
<frameset rows="*" cols = "125,*" frameborder="no" framespacing="0"
border="0">
<frame src="sample_topleft.html" scrolling="no" frameborder="no"
framespacing="0" border="0" noresize>
<frame name="titleframe" src="sample_topright.html" scrolling="no"
frameborder="no" framespacing="0" border="0" noresize>
</frameset>
<frame name="sample_bottom" src="sample_bottom.html" noresize>
</FRAMESET>

and delete [sample_top.html]. This might make it more easy to see the
nesting.

Then calling from sample_bottom.html the following:

parent.frames['titleframe'].document.getElementByID('variable')="Variable
text: "+txt;

Wouter
Jul 20 '05 #2
Paul wrote:
I have a simple frame-based application where title information
appears in a top frame and a lower frame contains the content
for the application. One of the needs for this app is for a
status line in the upper frame to be updated when certain
actions are taken in the lower frame.

In the top frame, I have a line of text wrapped with SPAN tags
and assigned a unique ID attribute.

In the lower frame, I run a JS function that looks up the ID
using the DOM (getElementById()) and then assigns the new
text to the innerText of that element. Under IE, this works
perfectly fine. Under NN7 the text in the upper frame doesn't
change (although it does appear that it is getting set).

Any ideas? A sample app appears below.


Yeah. innerText is IE only. Use innerHTML (although there are better
ways to do it).

--
Randy
Chance Favors The Prepared Mind
comp.lang.javascript FAQ - http://jibbering.com/faq/

Jul 20 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Jim Cobban | last post by:
I have a set of web pages that are organized in pairs. One of each pair contains a graphic and the other is an extended description of the graphic. I am trying to set it up that selecting a single...
1
by: P | last post by:
Hello, I am having a difficult time updating a record via a stored procedure using the gridview and sqldatasource. I cannot seem to be able to find a way to set everything up so that I can pass...
14
by: el_sid | last post by:
Our developers have experienced a problem with updating Web References in Visual Studio.NET 2003. Normally, when a web service class (.asmx) is created, updating the Web Reference will...
5
by: Mark R. Dawson | last post by:
Hi all, I may be missing something with how databinding works but I have bound a datasource to a control and everything is great, the control updates to reflect the state of my datasource when I...
14
by: Roger Withnell | last post by:
How to I find out what size text the browser is set to? Thanks in anticipation.
0
by: Michael Kellogg | last post by:
I have a problem wherein a query that updates a GridView doesn't seem to really stay in sync with a label I have above the GridView. I have a GridView object that I'm updating with information...
1
by: Steve | last post by:
hi, i'm fairly new to java and am experimenting with various swing components. as far as I know at this time, when a change occurs in the text i want to display, in order to show it, I have to...
14
by: BrendanMcPherson | last post by:
Hello, Im try to do some tricks to help make a "Search Many Sites from One Location". http://www.act.org.au/b_nexus.htm What I have decided to do is this: 1. You can choose which site you...
0
by: =?Utf-8?B?YmFrZXJzaGFjaw==?= | last post by:
Unless my app is EXTREMELY simple, I get the cross-threading error message regularly when updating controls on a Windows form. My latest example involves a dll that runs a System.Threading.Timer,...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.