471,319 Members | 1,947 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,319 software developers and data experts.

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.

Jul 23 '05 #1
2 2671
J Krugman wrote:
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.
if(opener){ //window A is available }}

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

if(opener.document.forms["formName"].elements["elementName"])

Mick
Any advice on implementing this would be much appreciated.

TIA,

jill

Jul 23 '05 #2
J Krugman wrote:
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.


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(Element)
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
Jul 23 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

9 posts views Thread by Harald Massa | last post: by
11 posts views Thread by Jochen Neyens | last post: by
21 posts views Thread by dast | last post: by
2 posts views Thread by ne.seri | last post: by
3 posts views Thread by =?Utf-8?B?U2VraGFy?= | last post: by
5 posts views Thread by AeonOfTime | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.