473,659 Members | 2,685 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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.d ocument.forms[0].myHiddenField. value=returnVal ue;
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.d ocument.forms[0].myHiddenField. value=returnVal ue;
window.opener.d ocument.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 2967
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.d ocument.forms[0].myHiddenField. value=returnVal ue;
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.d ocument.forms[0].myHiddenField. value=returnVal ue;
window.opener.d ocument.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.f DoStuff();

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

*** popTest2.php ***
<html>
<head>
<script language="javas cript">
function fDoStuff() {
window.opener.d ocument.forms[0].myHiddenField. value='bennie';
window.opener.f DoStuff();
self.close();
}
</script>
</head>
<body onload="fDoStuf f();">

<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
2929
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 where there is no scripts allowed running (the software is from Opentext called Livelink)- therefore I need javascript to do the tasks listed below: 1. validate the form - this has been completed 2. pop up another window that will go ahead and...
1
6591
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 when the popup closes and puts the control value (date selected) into the textbox on my main form, I can't get my onchnage event to fire (i.e., which should load a datagrid). This is the sub that the calendar pop-up form uses when the date is...
15
10089
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 popup has a DataGrid on it and the page.load function DataBinds as you'd expect. I have Code-Behind in C# to emit a call to a JavaScript function which
0
8427
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
8330
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
8746
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8626
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...
0
5649
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4334
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2749
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
1975
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1737
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.