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

Discussion in 'Javascript' started by Giakko, Apr 13, 2006.

  1. Giakko

    Giakko Guest

    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>



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

    Simone
     
    Giakko, Apr 13, 2006
    #1
    1. Advertising

  2. Giakko

    Giakko Guest

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

    but it doesn't work!
     
    Giakko, Apr 13, 2006
    #2
    1. Advertising

  3. 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='TEST SUCCEDED!!';


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

    Richard.
     
    Richard Cornford, Apr 13, 2006
    #3
  4. Giakko

    Guest

    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='TEST 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, 2006
    #4
  5. Giakko

    Martyr2 Guest

    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. :)
     
    Martyr2, Apr 13, 2006
    #5
  6. Giakko

    Randy Webb Guest

    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='TEST 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/
     
    Randy Webb, Apr 13, 2006
    #6
  7. Giakko

    Martyr2 Guest

    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. :)
     
    Martyr2, Apr 14, 2006
    #7
  8. Giakko

    Randy Webb Guest

    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/
     
    Randy Webb, Apr 14, 2006
    #8
  9. Giakko

    Martyr2 Guest

    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/
     
    Martyr2, Apr 14, 2006
    #9
  10. Giakko

    Randy Webb Guest

    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/
     
    Randy Webb, Apr 14, 2006
    #10
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. sonic
    Replies:
    1
    Views:
    126
  2. Jake Barnes
    Replies:
    2
    Views:
    167
    Thomas 'PointedEars' Lahn
    Mar 12, 2006
  3. window.opener, form.opener?

    , Jul 14, 2006, in forum: Javascript
    Replies:
    5
    Views:
    287
  4. Replies:
    3
    Views:
    217
  5. Klaus Jensen
    Replies:
    2
    Views:
    171
    David Dorward
    Aug 21, 2007
Loading...

Share This Page