window.opener.getElementById('myDiv').innerHTML ... doesn't work!

G

Giakko

Dear reader..
i have a page that opens a popup window
from this popup window i have to change some opener divs innerHTML
content,
how can i do?
this is how i do, (and it doens't work):

THE MAIN WINDOW:
<div id="'myDiv'"></div>
<input type="button"
onClick="MM_openBrWindow('test.htm','testWin','width=370,height=200')"
value="Open Test">


THE POPUP WINDOW (test.htm):
<script language=javascript>
window.opener.getElementById('myDiv').innerHTML='TEST SUCCEDED!!';
</script>
 
G

Giakko

i tried also:
window.opener.document.getElementById('myDiv').innerHTML='TEST
SUCCEDED!!';

but it doesn't work!
 
R

Richard Cornford

Giakko wrote:
THE MAIN WINDOW:
<div id="'myDiv'"></div>
<snip> ^
That apostrophe makes this ID different form the one you are trying to
look up.
window.opener.getElementById('myDiv').innerHTML='TEST SUCCEDED!!';

The - opener - is a window object and does not have a getelEmentById -
method. Use - opener.document.getElementById -.

Richard.
 
A

AbstraktMethodz

Richard said:
Giakko wrote:

<snip> ^
That apostrophe makes this ID different form the one you are trying to
look up.


The - opener - is a window object and does not have a getelEmentById -
method. Use - opener.document.getElementById -.

Richard.

also, innerHTML is IE only
 
M

Martyr2

Just so you know, innerHTML does work in Firefox (tested in 1.5) but is
becoming depreciated. They recommend you go through the W3C compliant
DOM methods instead. I don't know if I neccessarily agree with it, but
that is what they recommend.

Richard is right on all counts though. Just my two cents. :)
 
R

Randy Webb

(e-mail address removed) said the following on 4/13/2006 4:37 PM:
also, innerHTML is IE only

Who fed you that line of BS and how much did you pay for it? I have some
more BS like that if you are buying.
 
M

Martyr2

Oh I know it is much easier from a coding standpoint. I just read on
the W3C site that they recommend avoiding innerHTML because it could
possibly introduce content into the dom structure that can not be
referenced later. Granted it is a working draft I read it from. The
exact phrase being...

Quote: "Assistive technologies such as screen readers rely on the
Document Object Model (DOM) to interpret the semantics in HTML for a
different modality. Given this, the document.write() and innerHTML()
methods can render content invalid (and inaccessible via DOM) after the
fact."

Does this mean never ever use it because it is bad? Bah, I would still
use it and I do use it regularly. It's all good. Just make sure you use
valid html structure and the DOM will be fine. But point well taken
Tony. :)
 
R

Randy Webb

Martyr2 said the following on 4/13/2006 9:11 PM:

Please quote what you are replying to.

If you want to post a followup via groups.google.com, don't use the
"Reply" link at the bottom of the article. Click on "show options" at
the top of the article, then click on the "Reply" at the bottom of the
article headers.
Oh I know it is much easier from a coding standpoint. I just read on
the W3C site that they recommend avoiding innerHTML because it could
possibly introduce content into the dom structure that can not be
referenced later. Granted it is a working draft I read it from. The
exact phrase being...

That isn't a flaw in innerHTML, it is a flaw in the ability of the
person using innerHTML.
Quote: "Assistive technologies such as screen readers rely on the
Document Object Model (DOM) to interpret the semantics in HTML for a
different modality. Given this, the document.write() and innerHTML()
methods can render content invalid (and inaccessible via DOM) after the
fact."

Screen Readers that can process JS and add structure to the DOM? WOW.
But, I never did care much for what the W3C has to say.
 
M

Martyr2

Randy said:
Martyr2 said the following on 4/13/2006 9:11 PM:

Please quote what you are replying to.

If you want to post a followup via groups.google.com, don't use the
"Reply" link at the bottom of the article. Click on "show options" at
the top of the article, then click on the "Reply" at the bottom of the
article headers.


That isn't a flaw in innerHTML, it is a flaw in the ability of the
person using innerHTML.

I never said it was a flaw, it is just depreciated because of the
problems it could introduce if misused. Which I why I am guessing they
have not removed it from the firefox implementation.
 
R

Randy Webb

Martyr2 said the following on 4/14/2006 12:36 AM:
I never said it was a flaw, it is just depreciated because of the
problems it could introduce if misused. Which I why I am guessing they
have not removed it from the firefox implementation.

My apologies if my thought's didn't come across right. It wasn't a
contradiction but more of an added thought to the conversation.

If people have problems using innerHTML (which is what they have) then
it isn't a problem with innerHTML itself but rather the people who use
it not having an understanding of what it does and doesn't do.

That problem (lack of understanding) is what leads people to cry
"innerHTML is broken" and then some standards body will try to
"deprecate it" because it is "broken" when what is really broken is the
knowledge level of people using it.
 

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

Forum statistics

Threads
473,764
Messages
2,569,566
Members
45,041
Latest member
RomeoFarnh

Latest Threads

Top