473,378 Members | 1,138 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

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

Best way to fire an event in the opener from a popup

TH
Hi there

What's the best way for a popup to cause an event to fire in the
opener? I've got a popup which currently returns a value to the opener
by setting a hidden input in the opener:

window.opener.document.forms[0].myHiddenField.value=returnValue;
window.close();

I then want the opener window to perform some work on the returned
value. The best I've come up with so far is to put a button on the
opener page, try to hide it with css, give it an onclick value which
calls the function I want to run, then have the popup click it:

window.opener.document.forms[0].myHiddenField.value=returnValue;
window.opener.document.forms[0].myHiddenButton.click();
window.close();

Is there any less clunky method than using an invisible button like
this?

Thanks, TH.

Dec 4 '06 #1
2 2946
TH wrote:
Hi there

What's the best way for a popup to cause an event to fire in the
opener? I've got a popup which currently returns a value to the opener
by setting a hidden input in the opener:

window.opener.document.forms[0].myHiddenField.value=returnValue;
window.close();

I then want the opener window to perform some work on the returned
value. The best I've come up with so far is to put a button on the
opener page, try to hide it with css, give it an onclick value which
calls the function I want to run, then have the popup click it:

window.opener.document.forms[0].myHiddenField.value=returnValue;
window.opener.document.forms[0].myHiddenButton.click();
window.close();

Is there any less clunky method than using an invisible button like
this?

Thanks, TH.
Just execute the same method that the button does when clicked. For
instance if it calls "fDoStuff()" in the onclick event, just call it
from the child window like this: window.opener.fDoStuff();

*** popTest.php ***
<html>
<head>
<script language="javascript">
function fDoStuff() {
alert(document.forms[0].myHiddenField.value);
}
function fPopIt() {
window.open('popTest2.php', 'mywin');
}
</script>
</head>
<body onload="fPopIt();">
<form>
<input type="hidden" name="myHiddenField" id="myHiddenField">
</form>
<body>
</html>

*** popTest2.php ***
<html>
<head>
<script language="javascript">
function fDoStuff() {
window.opener.document.forms[0].myHiddenField.value='bennie';
window.opener.fDoStuff();
self.close();
}
</script>
</head>
<body onload="fDoStuff();">

<body>
</html>

Dec 4 '06 #2
TH
Cheers pangea!

Jan 4 '07 #3

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

Similar topics

2
by: Mike Button | last post by:
Hello all, I am really really desperate on what I should do, and I am asking for help from anyone in this newsgroup, here's the situation: I am creating a form that is being run on a server...
1
by: Kathy Burke | last post by:
Hi, I have a textbox and a calendar popup window. I got this from a posting (sorry, his name escapes me at the moment). It's nice and simple, so I like it, of course. Only problem I have is that...
15
by: H00ner | last post by:
Hello All Hope you can help Been pulling my hair out about a popup problem in ASP.NET. One of the forms i wrote requires the user to select a product from a list in a popup web form. the...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

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.