Communication between browser windows?

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

    #1

    Communication between browser windows?



    I need guidance on implementing the following functionality in
    JavaScript:

    User clicks on a link (or button) in browser window A that brings
    up a separate browser popup window B featuring a list/table of 500+
    clickable items; clicking on any one of these items causes it (or
    rather its label string) to be added to the contents of a textarea
    field in the original page A, perhaps after checking that it has
    not been added already.

    The document in window B must somehow know about the document in
    window A, and the script must behave appropriately (i.e. do nothing)
    if the document in window A disappears for some reason (e.g. user's
    navigation, window closing, etc.) and the user clicks on an item
    in window B.

    Any advice on implementing this would be much appreciated.

    TIA,

    jill
    --
    To s&e^n]d me m~a}i]l r%e*m?o\v[e bit from my a|d)d:r{e:s]s.

  • Mick White

    #2
    Re: Communication between browser windows?

    J Krugman wrote:
    [color=blue]
    > I need guidance on implementing the following functionality in
    > JavaScript:
    >
    > User clicks on a link (or button) in browser window A that brings
    > up a separate browser popup window B featuring a list/table of 500+
    > clickable items; clicking on any one of these items causes it (or
    > rather its label string) to be added to the contents of a textarea
    > field in the original page A, perhaps after checking that it has
    > not been added already.
    >
    > The document in window B must somehow know about the document in
    > window A, and the script must behave appropriately (i.e. do nothing)
    > if the document in window A disappears for some reason (e.g. user's
    > navigation, window closing, etc.) and the user clicks on an item
    > in window B.[/color]

    if(opener){ //window A is available }}

    or better yet, look for a known object in window A.

    if(opener.docum ent.forms["formName"].elements["elementNam e"])

    Mick[color=blue]
    >
    > Any advice on implementing this would be much appreciated.
    >
    > TIA,
    >
    > jill[/color]

    Comment

    • Thomas 'PointedEars' Lahn

      #3
      Re: Communication between browser windows?

      J Krugman wrote:[color=blue]
      > I need guidance on implementing the following functionality in
      > JavaScript:
      >
      > User clicks on a link (or button) in browser window A that brings
      > up a separate browser popup window B featuring a list/table of 500+
      > clickable items; clicking on any one of these items causes it (or
      > rather its label string) to be added to the contents of a textarea
      > field in the original page A, perhaps after checking that it has
      > not been added already.
      >
      > The document in window B must somehow know about the document in
      > window A, and the script must behave appropriately (i.e. do nothing)
      > if the document in window A disappears for some reason (e.g. user's
      > navigation, window closing, etc.) and the user clicks on an item
      > in window B.
      >
      > Any advice on implementing this would be much appreciated.[/color]

      In the "onclick" event handler of the triggering element in browser
      window A call window.open(). You may want to cancel the event by
      returning `false' to the handler. In the "onchange" event handler of
      the triggering "select" element or (better) in the "onclick" event
      handler of the triggering "add" button in window B, read the value
      or text of the currently selected item and append it to the "value"
      property of the (HTML)TextArea( Element) object in the Window referenced
      by the "opener" property of the current Window/global object, possibly
      delimited with newline ("\n"). You need to check if "opener" is a valid
      object reference and if it has not been closed and if has such an
      (HTML)TextArea( Element) object before.

      Checking that the value has not been added already is somewhat difficult
      as you need to find a way to tell one entry from the other, perhaps
      using Regular Expression matching. Probably a (HTML)Select(El ement)
      object would do better than a (HTML)TextArea( Element) object. How you
      add options to a "select" element should be in the FAQ or available via
      Google Groups search. You could instead disable the currently selected
      option in window B after its value/text has been added to the "textarea"
      element in window A but I doubt this can be implemented cross-browser.

      Don't forget to provide a server-side alternative for users who have
      no client-side script support available.


      HTH

      PointedEars

      Comment

      Working...