473,699 Members | 2,838 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

window.opener HELP!!

I have a normal window cotaining a form (named form1). The form has a text
input called imageURL. There is a button that, when clicked, opens a new
window that contains three frames (left, right and bottom.) In the right
frame is another form (named form2) with a hidden input (selected). When
form2 is submitted, I want the value of selected to be passed back to the
imageURL on form1 and then close.

The code I have tried is as follows:

(From my frame...)
<SCRIPT language="JavaS cript">
function passValues()
{
// pass variable back to parent window
window.opener.d ocument.form1.i mageURL.value =
document.form2. selected.value;
}
top.window.clos e();
</SCRIPT>

It closes just fine, but imageURL on form1 never changes.

Anyone with ideas on how to make this work is encouraged to offer their
help!!
Jul 23 '05 #1
3 6550
ctrl+alt+delete wrote:
In the right frame is another form (named form2) with a
hidden input (selected). When form2 is submitted, I want the value of
selected to be passed back to the imageURL on form1 and then close.
[...]
// pass variable back to parent window
window.opener.d ocument.form1.i mageURL.value =
document.form2. selected.value;


The opener opened the frameset's top window, not the frame your statement
is in. So you want to use top.opener... instead of window.opener.. . here.
In addition, since the popup is not modal, you should avoid error
messages caused by an already closed opener window (or by having another
document in the opener already) by testing if the used properties and
objects are still available:

var oOpener, oOpenerForm, oOpenerElement;
if (
(oOpener = top.opener)
&& !oOpener.closed
&& (oOpenerForm = top.opener.docu ment.forms["form1"])
&& (oOpenerElement = oOpenerForm.ele ments["imageURL"])
) {
oOpenerElement. value
= document.forms["form2"].elements["selected"].value;
}

This looks a little laborious compared to waht you had, but it's
essential to avoid error messages.

ciao, dhgm
Jul 23 '05 #2
Hey, thanks a lot for the quick reply! I will try out what you suggested and
post my results.

"Dietmar Meier" <us************ ***@innoline-systemtechnik.d e> wrote in
message news:36******** *****@individua l.net...
ctrl+alt+delete wrote:
In the right frame is another form (named form2) with a
hidden input (selected). When form2 is submitted, I want the value of
selected to be passed back to the imageURL on form1 and then close.
[...]
// pass variable back to parent window
window.opener.d ocument.form1.i mageURL.value =
document.form2. selected.value;


The opener opened the frameset's top window, not the frame your statement
is in. So you want to use top.opener... instead of window.opener.. . here.
In addition, since the popup is not modal, you should avoid error
messages caused by an already closed opener window (or by having another
document in the opener already) by testing if the used properties and
objects are still available:

var oOpener, oOpenerForm, oOpenerElement;
if (
(oOpener = top.opener)
&& !oOpener.closed
&& (oOpenerForm = top.opener.docu ment.forms["form1"])
&& (oOpenerElement = oOpenerForm.ele ments["imageURL"])
) {
oOpenerElement. value
= document.forms["form2"].elements["selected"].value;
}

This looks a little laborious compared to waht you had, but it's
essential to avoid error messages.

ciao, dhgm

Jul 23 '05 #3
Here's what I ended up going with and it works perfectly:

top.window.open er.document.for ms["form1"].elements["imageURL"].value =
"#Form.selected #";

Note: I am processing this script on a ColdFusion page, hence the use of
#Form.selected# .

Thanks again for the help. I wasn't sure how to reference the input back on
my original page.
"Dietmar Meier" <us************ ***@innoline-systemtechnik.d e> wrote in
message news:36******** *****@individua l.net...
ctrl+alt+delete wrote:
In the right frame is another form (named form2) with a
hidden input (selected). When form2 is submitted, I want the value of
selected to be passed back to the imageURL on form1 and then close.
[...]
// pass variable back to parent window
window.opener.d ocument.form1.i mageURL.value =
document.form2. selected.value;


The opener opened the frameset's top window, not the frame your statement
is in. So you want to use top.opener... instead of window.opener.. . here.
In addition, since the popup is not modal, you should avoid error
messages caused by an already closed opener window (or by having another
document in the opener already) by testing if the used properties and
objects are still available:

var oOpener, oOpenerForm, oOpenerElement;
if (
(oOpener = top.opener)
&& !oOpener.closed
&& (oOpenerForm = top.opener.docu ment.forms["form1"])
&& (oOpenerElement = oOpenerForm.ele ments["imageURL"])
) {
oOpenerElement. value
= document.forms["form2"].elements["selected"].value;
}

This looks a little laborious compared to waht you had, but it's
essential to avoid error messages.

ciao, dhgm

Jul 23 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
16028
by: fogwolf | last post by:
First a basic outline of what I am trying to do: I want to have a page spawn a pop-up when you click "submit" on its form. On this pop-up page there will be another form. When you click "submit" on the pop-up's form I want the pop-up to close & a new page to load in the "parent" window/page. I have this working in IE but cannot get it to work in Firefox. The parent window correctly loads the new page after submitting from the pop-up,...
1
4562
by: ian.michel | last post by:
I have a parent window that pushes a new window object onto an Array with the following code : OpenChild() { //totalNumWindowsCreated is global totalNumWindowsCreated = totalNumWindowsCreated + 1; childWnds.push(window.open(link, "child" +
19
31051
by: Darren | last post by:
I have a page that opens a popup window and within the window, some databse info is submitted and the window closes. It then refreshes the original window using window.opener.location.reload(). The problem is that after the reload, it brings you right to the top of the page. When I click 'refresh" on the original page, it brings me back to the original viewing position. Is there a way to duplicate this in from the popup window. Also,...
2
2292
by: RWC | last post by:
Hello, I am new to JavaScript but until now, have felt my way along fairly successfully. I have a page showing an image to the user. I use window.open to open a separate page, listing a bunch of different images that the user can select. When the user clicks "Submit", I'd like the image selection page to close and update the image on the originating page. To "play around" with this command until I can use it successfully, I wrote...
4
9717
by: Phil Powell | last post by:
I thought this would work but it seems to not work neither in Netscape nor in IE: <script type="text/javascript"> <!-- // OBTAINED FROM http://www.javascripter.net/faq/settinga.htm // NOTE THAT IF YOU SET days TO -1 THE COOKIE WILL BE SET TO YESTERDAY
5
7528
by: asadhkhan | last post by:
I have the following code which works correctly in IE 6, but in IE 7, Fire Fox 2.0 and Netscape 8 it does not work. I have a main page where a button calls this pop-up and uploads a file once you click the attach it should upload file and close the window and send back control to Main page.. But it is not happening.. CODE: ========= <script LANGUAGE="JavaScript"> if ((window.opener != null) && (! window.opener.closed)) {
1
8447
by: Vexander | last post by:
Hi I am trying to right a script that closes a popup and then refreshes the pener to specific URL If have this that works form me <script type="text/javascript"> window.opener.location.href = 'http://localhost/fmsuite/Sales/Document.asp? docNumber=' + <%=Request.QueryString("docNumber")%>; window.opener.focus(); self.close() </script>
0
8685
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8612
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9171
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8880
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
6532
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4373
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4625
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3053
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2342
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.