Cross-Frames Again (Still?)

A

ashore

Guys, what's wrong with this snippet of JS? (Fails in both IE and
Moz, and with several variations of the referencing.)

parent.frames["top"].document.getElementById("whom") = "whatever";
alert (parent.frames["top"].document.getElementById("whom"));

In frame "top" I have <SPAN ID="whom"></SPAN>

Thanks heaps. (Or is it 'stacks'?)

-AS
 
E

Evertjan.

ashore wrote on 04 aug 2007 in comp.lang.javascript:
Guys, what's wrong with this snippet of JS? (Fails in both IE and
Moz, and with several variations of the referencing.)

parent.frames["top"].document.getElementById("whom") = "whatever";

You cannot assign anything to a DOM object.

You would need something like

......getElementById("whom").value = "whatever";

or

......getElementById("whom").innerHTML = "whatever";

alert(parent.frames["top"].document.getElementById("whom"));

A DOM object usually has no default value or innerHTML string.
In frame "top" I have <SPAN ID="whom"></SPAN>

So .innerHTML would be the one.
 
T

Thomas 'PointedEars' Lahn

ashore said:
Guys, what's wrong with this snippet of JS? (Fails in both IE and
Moz, and with several variations of the referencing.)

"Does not work" is a useless error description. [psf 4.11]
parent.frames["top"].document.getElementById("whom") = "whatever";
alert (parent.frames["top"].document.getElementById("whom"));

Use space characters for indentation, not tab characters.
In frame "top" I have <SPAN ID="whom"></SPAN>

Since Window objects have a defined `top' property to refer to the
topmost frameset they are in, you should avoid naming a frame so.

Furthermore, you are attempting to assign a string to a DOM object
reference which is almost certain to fail. (Have I not posted before
that you should observe the error messages more closely, and that you
should post them here?)


Creating a new thread for the same problem that was asked in a thread
created only hours ago may be perceived as being obtrusive, and
therefore go ignored. Usenet is no real-time communication medium, no chat.


PointedEars
 
A

ashore

Sorry to be a nuisance, and thanks for the help. But these both fail
in IE7, apparently OK in Moz:

parent.frames["top"].document.getElementById("whom").innerHTML =
"whatever";

parent.frames["top"].document.getElementById("whom").value =
"whatever";

Again, in frame "top" I have <SPAN ID="whom"></SPAN>

Any other suggestions?
-AS
 
T

Thomas 'PointedEars' Lahn

ashore said:
Sorry to be a nuisance, and thanks for the help. But these both fail
in IE7, apparently OK in Moz:

parent.frames["top"].document.getElementById("whom").innerHTML =
"whatever";

innerHTML remains proprietary. You want to avoid such reference worms
and do some feature tests on run time.

http://www.jibbering.com/faq/faq_notes/not_browser_detect.html#bdFD
parent.frames["top"].document.getElementById("whom").value =
"whatever";

HTMLElement objects do not have a `value' property. Stop guessing
around and go read the specs for a change.

http://www.w3.org/TR/DOM-Level-2-HTML/html.html#ID-58190037
Again, in frame "top" I have <SPAN ID="whom"></SPAN> ^^^
Any other suggestions?

Not until you follow *all* the advice you have already been given.


PointedEars
 
E

Evertjan.

ashore wrote on 04 aug 2007 in comp.lang.javascript:
Sorry to be a nuisance, and thanks for the help. But these both fail
in IE7, apparently OK in Moz:

parent.frames["top"].document.getElementById("whom").innerHTML =
"whatever";

Did you have the name "top" declared in the frames declaration?

Perhaps try document.parent or window.parent.
parent.frames["top"].document.getElementById("whom").value =
"whatever";

Again, in frame "top" I have <SPAN ID="whom"></SPAN>

Any other suggestions?

PLEASE always quote, usenet is not email, there are ther readers too.

=================

Anyway, using frames is becomming antique,
since you can do such things better with css and serverside inserts,
[or perhaps iframes if you need to go cross domain].

That's the reason I am not going to test it myself.
 
R

Richard Cornford

Evertjan said:
ashore wrote on 04 aug 2007 in comp.lang.javascript:
Guys, what's wrong with this snippet of JS? (Fails in both IE
and Moz, and with several variations of the referencing.)

parent.frames["top"].document.getElementById("whom") = "whatever";

You cannot assign anything to a DOM object.
<snip>

More precisely; you cannot assign (anything) to a function call. It
doesn't matter what the call may return, a function call just cannot
work as the left hand side of an assignment operation. Strictly it is a
syntax error, which may explain why no runtime errors follow form
attempts to execute it.

Richard.
 
A

ashore

Thanks, all - you've really helped. The following is working for me
in FF and IE7:

parent.frames["upper"].document.getElementById("levelId").innerHTML
= level;

-AS
 
D

Dr J R Stockton

In comp.lang.javascript message <[email protected]>, Sat,
Creating a new thread for the same problem that was asked in a thread
created only hours ago may be perceived as being obtrusive, and
therefore go ignored. Usenet is no real-time communication medium, no chat.

And the latter is why one should, in the attribution, give the date/time
of the previous article. It is not mandatory; but it is sensible.

Your SigSep is misplaced.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,581
Members
45,057
Latest member
KetoBeezACVGummies

Latest Threads

Top