window.opener lost in postback

F

Frank

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
 
M

Marc

Frank said:
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...)
 
R

Richard Maher

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
 
F

Frank

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
 
F

Frank

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,743
Messages
2,569,478
Members
44,898
Latest member
BlairH7607

Latest Threads

Top