how to fill some field in parent window from a child window

Discussion in 'Javascript' started by Song Zhang, Sep 26, 2003.

  1. Song Zhang

    Song Zhang Guest

    I need to write asp/script/html code to fill the following function.
    1. When a page appA.mycom.com/aa.html (aa.html code shown below) is visited
    from my site, a user can click the button "Launch", which launches a new
    window with a page from a different domain, say appB.mycom.com/bb.html. In
    the form myForm of aa.html, there is a field called URL.

    <html> <body>

    <form name="myForm">
    <input type="button" value="Launch" onclick="window.open('bb.html')">
    <input type="text" name="URL" value="Nothing Here Initially">
    </form>

    </body></html>

    2. At bb.html (code shown below), there is a button "Fill Text", once
    clicked, I want some text from bb.html to be filled in the URL field of
    myForm in aa.html via opener.document.myForm.URL.value = text.

    <HTML>
    <SCRIPT TYPE='text/javascript' LANGUAGE='Javascript'>
    function foo(text) {opener.document.myForm.URL.value = text;}
    </SCRIPT>

    <BODY> <Form>
    <input type='button' value='Fill Text' onclick='foo("Hello world ")'>
    </Form> </BODY>
    </HTML>

    The problem is that when I clicked the button "Fill Text" on bb.html, I got
    an error: access denied. This reminds me sth fundamental. That is, do I have
    to implement this from server side? Thanks.

    _________________________________________________________________
    Instant message during games with MSN Messenger 6.0. Download it now FREE!
    http://msnmessenger-download.com
    Song Zhang, Sep 26, 2003
    #1
    1. Advertising

  2. Song Zhang

    Doug Turner Guest

    Well, I am too lazy to try this out ... but, I believe if put this
    javascript statement:

    document.domain = "mycom.com";

    in both the "opener" and the "opened" window, you will eliminate the
    access denied error.

    On Fri, 26 Sep 2003 10:58:15 -0400, "Song Zhang" <>
    wrote:

    >I need to write asp/script/html code to fill the following function.
    >1. When a page appA.mycom.com/aa.html (aa.html code shown below) is visited
    >from my site, a user can click the button "Launch", which launches a new
    >window with a page from a different domain, say appB.mycom.com/bb.html. In
    >the form myForm of aa.html, there is a field called URL.
    >
    ><html> <body>
    >
    ><form name="myForm">
    ><input type="button" value="Launch" onclick="window.open('bb.html')">
    ><input type="text" name="URL" value="Nothing Here Initially">
    ></form>
    >
    ></body></html>
    >
    >2. At bb.html (code shown below), there is a button "Fill Text", once
    >clicked, I want some text from bb.html to be filled in the URL field of
    >myForm in aa.html via opener.document.myForm.URL.value = text.
    >
    ><HTML>
    ><SCRIPT TYPE='text/javascript' LANGUAGE='Javascript'>
    > function foo(text) {opener.document.myForm.URL.value = text;}
    ></SCRIPT>
    >
    ><BODY> <Form>
    ><input type='button' value='Fill Text' onclick='foo("Hello world ")'>
    ></Form> </BODY>
    ></HTML>
    >
    >The problem is that when I clicked the button "Fill Text" on bb.html, I got
    >an error: access denied. This reminds me sth fundamental. That is, do I have
    >to implement this from server side? Thanks.
    >
    >_________________________________________________________________
    >Instant message during games with MSN Messenger 6.0. Download it now FREE!
    >http://msnmessenger-download.com
    >
    Doug Turner, Sep 29, 2003
    #2
    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. davout
    Replies:
    0
    Views:
    541
    davout
    Apr 18, 2004
  2. Jeff Rodriguez
    Replies:
    23
    Views:
    1,086
    David Schwartz
    Dec 9, 2003
  3. Noel Dolan
    Replies:
    0
    Views:
    217
    Noel Dolan
    Jul 18, 2004
  4. Spammay Blockay
    Replies:
    1
    Views:
    402
    Dietmar Meier
    Feb 4, 2005
  5. Bitswapper
    Replies:
    5
    Views:
    119
    Prasad, Ramit
    Aug 27, 2013
Loading...

Share This Page