how to passing value from popup to the parent window as a variable
which I can access and process the variable(string) in parent window?
such as from popup page, we have var_from_popup="abc", after the popup
closed, then from parent window, we can use alert(var_from_popup) and
it will show us the "abc"?
10 11751
Use window.opener to refer to the parent, then you can set whatever variable you wish in the parent window.
there is a variable var varwindow in primary window;
from popup, i set
window.opener.varwindow="abc"
then from primary window , i use alert(varwindow) but
it write as "underfinded" but not "abc"..why?
not okay..why? it still show underfine.. from Mainpage.htm -
-
var item1;
-
window.open("popup.htm", "name", "width=255,height=455");
-
alert(item1);
-
from popup.htm -
-
<script type="text/javascript">
-
-
function get_value()
-
{
-
window.opener.item1="123";
-
}
-
</script>
-
<form>
-
<textarea name='itembox' rows=10 cols=30></textarea>
-
<input type="button" onclick="get_value();window.close()" value="Submit">
-
</form>
-
@perhapscwk
you are mistaking properties with variables. try the code I posted.
I try alert(window.item1) but still not okay..
It's going to be undefined because there simply isn't enough time before you alert it. When you call window.open, it's more or less asynchronous and moves onto the next line (the alert) without waiting for the window to load. You may not notice this as much on faster computers/simple pages. Even if it was synchronous, your code assumes item1 has already been set, but it's set from a button click.
so how to pass back value from popup to primary window?
i use showmodaldialog ...it okay but not work for firefox 2..
@perhapscwk
That part works. It's just that you're trying to alert it too quickly. If, for example, you use a button to alert it in the parent window and click it after you click the pop-up window button, it should work.
i use showmodaldialog ...it okay but not work for firefox 2..
showModalDialog support was added in Firefox 3. If you want to support older browsers, either use a normal window.open or write your own pseudo-modal dialog.
gits 5,390
Expert Mod 4TB
yes ... in case you use a normal window.open() you need to implement a mechanism that 'synchronizes' those async operations you trigger. how to do that best, depends a bit on your needs, or better, needed flow of your code.
kind regards
Sign in to post your reply or Sign up for a free account.
Similar topics
by: veganeater |
last post by:
Hi Everyone,
I was wondering if there was a way to pass a variable to a popup window. The
purpose is make it so when a user clicks on a specific region/link of the
glossary page, a popup opens...
|
by: Davey |
last post by:
I have a website which has a popup window (this only opens when the user
chooses to open it). In the popup window I have a <select> control which
lists a selection of "classes". Each class has a...
|
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...
|
by: Aaron |
last post by:
I am having a little difficulty with a relatively simple task.
I have a parent webform. I have a javascript attribute added to a button to
open a new window when clicked.
The user fills in a...
|
by: ABC |
last post by:
I has a parent and a popup lookup ASP.NET Form. Both has javascript.
I test the popup window's window.Form1.SelectedProductCode.value has a
value. But don't know why the return variable "retvar"...
|
by: michael |
last post by:
let me keep it clean, quick and simple.
I am passing a variable into another window and am reassigning the
value on the new page -
window.document...value = opener.document.
....value
and...
|
by: Cordouan |
last post by:
I know this looks like it has been answered 1000 times but I have a
slightly different problem.
I am dealing with forms in order to populate a database.
2 windows :
-Main window with my main...
|
by: pingalkar |
last post by:
Hi,
In my application, I call one popup winodow by using this link..
<a href="#" onClick="return showWindow('1','XYZ');">
<img src="images/magnifier.gif" ALT="Chemicals"...
|
by: meenakshia |
last post by:
hi forum
i have read a lot of articles regarding passing data from popup to parent up but i m looking for the opposite
that is
from parent to popup window
pls help me in this regard
i have...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
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...
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
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: 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,...
|
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...
|
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,...
|
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...
|
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...
| |