Javascript that does not work in NN/Mozilla

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • rnd

    Javascript that does not work in NN/Mozilla

    Hi all!

    could you kindly help me to solve a compatibility problem that involves
    Internet Explorer and NN/Mozilla.

    I created a html page that contains a form (its name is "Modulo") and some
    text boxes. After clicking on a button, a popup appears.
    I tried to modify the text of "Testo" textbox from the popup windows by
    using the following javascript code:
    window.opener.M odulo.Testo.val ue=window.opene r.Modulo.Testo. value + " This
    will be added to Testo textbox!";

    The code is correctly run by Internet Explorer and the "Testo" textbox in
    the calling html page is successfully updated.
    When I try to open these pages with Mozilla, the javascript code that should
    update the textbox is ignored. How can I solve this problem?

    I hope that someone of you will be so kind to give me an answer.

    P.S. Please excuse me for my horrible English.

    Best regards to all the newsgroup.
    Mauro. --


  • Lasse Reichstein Nielsen

    #2
    Re: Javascript that does not work in NN/Mozilla

    "rnd" <nospam@nospamn ospamnospam.org > writes:
    [color=blue]
    > window.opener.M odulo.Testo.val ue=window.opene r.Modulo.Testo. value + " This
    > will be added to Testo textbox!";
    >
    > The code is correctly run by Internet Explorer[/color]

    I'll accept that it works, but I'll withhold the "correctly" . There is
    no reason for this code to work in any browser. It works in IE, but fails
    in most other browsers.

    The problem is the
    window.opener.M odulo
    part. It accesses the Modulo form as a property of the global (window)
    object of the opener. Only IE makes named forms available as global
    variables. A version that is compatible with IE, Mozilla and the W3C DOM
    is

    window.opener.d ocument.forms['Modulo'].elements['Testo'] +=
    " This will be added to Testo textbox!";

    This even works in Netscape 3 (Netscape 2 has no "opener" property).
    [color=blue]
    > P.S. Please excuse me for my horrible English.[/color]

    It's fine. I've seen much worse from allegedly native (US-)English
    speakers

    /L
    --
    Lasse Reichstein Nielsen - lrn@hotpop.com
    Art D'HTML: <URL:http://www.infimum.dk/HTML/randomArtSplit. html>
    'Faith without judgement merely degrades the spirit divine.'

    Comment

    • rnd

      #3
      Re: Javascript that does not work in NN/Mozilla

      Great!
      Thank you for your excellent answer!

      Best regards.
      Mauro. --


      Comment

      Working...