471,071 Members | 7,703 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

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

window.opener lost in postback

Hello everyone,

I have a problem that the window.opener variable is lost once my popup
page has a postback. On multiple pages they address this problem but I
cannot find a correct answer.

This is my situation:

I have a main page which shows invoices. When a user clicks on the
invoices they get a popup where they can alter the invoice which uses
postbacks because of direct changes in the database. Finally the user
can click a button to accept the invoice and then I need to change two
variables on the main page which opened this popup, the new invoice
fee and status (which is based on the button pressed). I dont want any
postbacks on the main page, therefore I simply want to pass these two
variables from the popup to the main page.

However, after a single postback on the popup page the window.opener
variable is gone and lost forever. Now I have seen solutions using
frames but I do not know how to go from there because I also pass some
variables from the main page to the popup.

Hope someone can help me,
Regards Frank

Mar 30 '07 #1
4 7976
"Frank" <f.********@gmail.comwrote in message
news:11**********************@n59g2000hsh.googlegr oups.com...
Hello everyone,

I have a problem that the window.opener variable is lost once my popup
page has a postback. On multiple pages they address this problem but I
cannot find a correct answer.

This is my situation:

I have a main page which shows invoices. When a user clicks on the
invoices they get a popup where they can alter the invoice which uses
postbacks because of direct changes in the database. Finally the user
can click a button to accept the invoice and then I need to change two
variables on the main page which opened this popup, the new invoice
fee and status (which is based on the button pressed). I dont want any
postbacks on the main page, therefore I simply want to pass these two
variables from the popup to the main page.

However, after a single postback on the popup page the window.opener
variable is gone and lost forever. Now I have seen solutions using
frames but I do not know how to go from there because I also pass some
variables from the main page to the popup.

Hope someone can help me,
Regards Frank
If you are able to capture the variables in the popup then you could get
those in a framepage as well... right?
in the window.onload of one of the frame pages you can use window.parent to
get javascript variables from... the parent...
even after a reload/submit you'll be able to get those but only if the
target of the form submit is 'self' of course...

search for window.parent
(or perhaps window.top to get easy access to the top frame instead of
parent.parent.parent which I have seen people doing...)
Mar 30 '07 #2
Hi Frank,
However, after a single postback on the popup page the window.opener
variable is gone and lost forever. Now I have seen solutions using
frames but I do not know how to go from there because I also pass some
variables from the main page to the popup.
FWIW this is how I "pass" (tell the details frame to "receive" parameters)
If there is a better way please let me know. It's not very modular but hey
:-)

Main Page (With scrolling select list of Invoices)
================================

detailLoc = parent.frames["entry_details"].location; // Global, set
onload
: : :

function showDetails()
{
if (selectRef.selectedIndex == 0) //First line is a Header line
return false;

detailLoc.reload(); // Trigger the onload event in the details
form - a bit kludgy?
parent.document.getElementById("main").rows="30px, 0px,*"; // Show the
details form
return true;
}

Details Page
========

function load()
{
chan =
parent.frames["cornucopiae"].document.getElementById("CornuCopiae");

try
{
selectRef =
parent.frames["queue_lookup"].document.getJobs.jobList;
getDetails();
}
catch(err)
{initData()};

}

function getDetails()
{
headColor =
parent.frames["cornucopiae"].document.getElementById("torso").style.backgrou
ndColor;

parent.frames["cornucopiae"].document.getElementById("torso").style.backgrou
ndColor = "Silver";
document.display.entryNumber.value =
selectRef.options[selectRef.selectedIndex].text.substring(0,
10);
return true;
}

function goBack()
{
selectRef.options[selectRef.selectedIndex].selected=false;

parent.frames["cornucopiae"].document.getElementById("torso").style.backgrou
ndColor = headColor;
parent.document.getElementById("main").rows="30px, *,0px";
return;
}

You (I) have to use the try/catch because when the "real" load of the
details page occurs, context and some variables are unavailable but when I
reload() they are.

Cheers Richard Maher

"Frank" <f.********@gmail.comwrote in message
news:11**********************@n59g2000hsh.googlegr oups.com...
Hello everyone,

I have a problem that the window.opener variable is lost once my popup
page has a postback. On multiple pages they address this problem but I
cannot find a correct answer.

This is my situation:

I have a main page which shows invoices. When a user clicks on the
invoices they get a popup where they can alter the invoice which uses
postbacks because of direct changes in the database. Finally the user
can click a button to accept the invoice and then I need to change two
variables on the main page which opened this popup, the new invoice
fee and status (which is based on the button pressed). I dont want any
postbacks on the main page, therefore I simply want to pass these two
variables from the popup to the main page.

However, after a single postback on the popup page the window.opener
variable is gone and lost forever. Now I have seen solutions using
frames but I do not know how to go from there because I also pass some
variables from the main page to the popup.

Hope someone can help me,
Regards Frank

Mar 31 '07 #3
Thanks Marc and Richard,
I will try to use the frames idea to save the variables. I tried it
once but it didnt work out, guess I'll have to try again!

Regards,
Frank

Apr 6 '07 #4
Help !

Well I tried to use frames. I currently have the mainwindow,
factuurOverzicht which opens a new window onclick, which is a frameset
called: factuurFrameset. In this frameset I pass the variables in the
querystring to the frame inside this frameset and load factuur.aspx
with the variables needed. This goes fine. Also, in the mainwindow
factuurOverzicht I set the opener of the factuurFrameset to
factuurOverzicht. Furthermore, from the frame factuur.aspx I can call
window.top.opener and retreive the opener for factuurOverzicht.

However, after I submit data to factuur.aspx (which is handled in
codebehind), such as for editing e.a., the frames and all still work
but I loose the window.top.opener. What could be wrong?

Regards,
Frank

On 6 apr, 11:37, "Frank" <f.f.nee...@gmail.comwrote:
Thanks Marc and Richard,
I will try to use the frames idea to save the variables. I tried it
once but it didnt work out, guess I'll have to try again!

Regards,
Frank

Apr 8 '07 #5

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

4 posts views Thread by Andrew Alger | last post: by
reply views Thread by Peter Morris [Droopy eyes software] | 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.