469,330 Members | 1,250 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,330 developers. It's quick & easy.

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

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','wid th=370,height=200')"
value="Open Test">
THE POPUP WINDOW (test.htm):
<script language=javascript>
window.opener.getElementById('myDiv').innerHTML='T EST SUCCEDED!!';
</script>

------------------------------------------------------------
how can i do to make it work?
thanks

Simone

Apr 13 '06 #1
11 39136
i tried also:
window.opener.document.getElementById('myDiv').inn erHTML='TEST
SUCCEDED!!';

but it doesn't work!

Apr 13 '06 #2

Giakko wrote:
<snip>
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='T EST SUCCEDED!!';


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

Richard.

Apr 13 '06 #3

Richard Cornford wrote:
Giakko wrote:
<snip>
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='T EST SUCCEDED!!';


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

Richard.


also, innerHTML is IE only

Apr 13 '06 #4
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. :)

Apr 13 '06 #5
Ab*************@gmail.com said the following on 4/13/2006 4:37 PM:
Richard Cornford wrote:
Giakko wrote:
<snip>
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='T EST SUCCEDED!!';

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

Richard.


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.

--
Randy
comp.lang.javascript FAQ - http://jibbering.com/faq & newsgroup weekly
Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/
Apr 13 '06 #6
Martyr2 wrote:
Just so you know, innerHTML does work in Firefox (tested in 1.5)
And Netscape, and Opera.
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.


If that's so, it's really a bad thing:
http://www.quirksmode.org/dom/innerhtml.html

innerHTML is about 3x faster than DOM methods in Mozilla 1.75, and 4x
faster in Opera 8.

Also, it's often much simpler from a coding standpoint.
Apr 13 '06 #7
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. :)

Apr 14 '06 #8
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.
<URL: http://www.safalra.com/special/googlegroupsreply/ >
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.
--
Randy
comp.lang.javascript FAQ - http://jibbering.com/faq & newsgroup weekly
Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/
Apr 14 '06 #9

Randy Webb wrote:
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.
<URL: http://www.safalra.com/special/googlegroupsreply/ >
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.


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.
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.
--
Randy
comp.lang.javascript FAQ - http://jibbering.com/faq & newsgroup weekly
Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/


Apr 14 '06 #10
Martyr2 wrote:
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...
Funny - I've never had a problem accessing content added by innerHTML
through the DOM
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."
"can render" - not "will render". It makes no sense to throw it out
because some people abuse it.

Some people abuse (<insert: pain medication/decongestant/spray
paint/etc.) - does that mean we get rid of (<insert: pain
medication/decongestant/spray paint/etc.)
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.
Exactly.
But point well taken
Tony. :)


Thank you

Apr 14 '06 #11
Martyr2 said the following on 4/14/2006 12:36 AM:
Randy Webb wrote:
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.
<URL: http://www.safalra.com/special/googlegroupsreply/ >
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.


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.

--
Randy
comp.lang.javascript FAQ - http://jibbering.com/faq & newsgroup weekly
Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/
Apr 14 '06 #12

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

1 post views Thread by fogwolf | last post: by
19 posts views Thread by Darren | last post: by
3 posts views Thread by Steve Wark | last post: by
3 posts views Thread by jan | last post: by
1 post views Thread by CARIGAR | last post: by
reply views Thread by zhoujie | last post: by
reply views Thread by suresh191 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.