Cross-Frames Again (Still?)

Discussion in 'Javascript' started by ashore, Aug 4, 2007.

  1. ashore

    ashore Guest

    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
    ashore, Aug 4, 2007
    #1
    1. Advertising

  2. ashore

    Evertjan. Guest

    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.



    --
    Evertjan.
    The Netherlands.
    (Please change the x'es to dots in my emailaddress)
    Evertjan., Aug 4, 2007
    #2
    1. Advertising

  3. ashore wrote:
    > 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
    --
    Prototype.js was written by people who don't know javascript for people
    who don't know javascript. People who don't know javascript are not the
    best source of advice on designing systems that use javascript.
    -- Richard Cornford, <f806at$ail$1$>
    Thomas 'PointedEars' Lahn, Aug 4, 2007
    #3
  4. ashore

    ashore Guest

    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
    ashore, Aug 4, 2007
    #4
  5. ashore wrote:
    > 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
    --
    Prototype.js was written by people who don't know javascript for people
    who don't know javascript. People who don't know javascript are not the
    best source of advice on designing systems that use javascript.
    -- Richard Cornford, <f806at$ail$1$>
    Thomas 'PointedEars' Lahn, Aug 4, 2007
    #5
  6. ashore

    Evertjan. Guest

    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.

    --
    Evertjan.
    The Netherlands.
    (Please change the x'es to dots in my emailaddress)
    Evertjan., Aug 4, 2007
    #6
  7. Evertjan wrote:
    > 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.
    Richard Cornford, Aug 4, 2007
    #7
  8. ashore

    ashore Guest

    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
    ashore, Aug 4, 2007
    #8
  9. In comp.lang.javascript message <>, Sat,
    4 Aug 2007 18:04:00, Thomas 'PointedEars' Lahn <>
    posted:

    >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.

    --
    (c) John Stockton, Surrey, UK. REPLYyyww merlyn demon co uk Turnpike 6.05.
    Web <URL:http://www.uwasa.fi/~ts/http/tsfaq.html> -> Timo Salmi: Usenet Q&A.
    Web <URL:http://www.merlyn.demon.co.uk/news-use.htm> : about usage of News.
    No Encoding. Quotes precede replies. Snip well. Write clearly. Mail no News.
    Dr J R Stockton, Aug 5, 2007
    #9
    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. amit
    Replies:
    0
    Views:
    378
  2. Markus Wankus
    Replies:
    8
    Views:
    1,074
    Markus Wankus
    Aug 12, 2003
  3. Robert Brewer

    IIS problems occuring (again? still?)

    Robert Brewer, Dec 8, 2003, in forum: Python
    Replies:
    0
    Views:
    276
    Robert Brewer
    Dec 8, 2003
  4. luqman
    Replies:
    20
    Views:
    940
    Juan T. Llibre
    Jul 6, 2007
  5. luqman
    Replies:
    0
    Views:
    333
    luqman
    Jul 5, 2007
Loading...

Share This Page