window.opener lost in postback

Discussion in 'Javascript' started by Frank, Mar 30, 2007.

  1. Frank

    Frank Guest

    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
     
    Frank, Mar 30, 2007
    #1
    1. Advertising

  2. Frank

    Marc Guest

    "Frank" <> wrote in message
    news:...
    > 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...)
     
    Marc, Mar 30, 2007
    #2
    1. Advertising

  3. 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" <> wrote in message
    news:...
    > 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
    >
     
    Richard Maher, Mar 31, 2007
    #3
  4. Frank

    Frank Guest

    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
     
    Frank, Apr 6, 2007
    #4
  5. Frank

    Frank Guest

    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" <> wrote:
    > 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
     
    Frank, Apr 8, 2007
    #5
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Andrew Bewley via DotNetMonster.com

    window to window communication (window.opener)

    Andrew Bewley via DotNetMonster.com, Feb 3, 2005, in forum: ASP .Net
    Replies:
    0
    Views:
    1,053
    Andrew Bewley via DotNetMonster.com
    Feb 3, 2005
  2. Peter Morris [Droopy eyes software]

    window.opener lost on postback

    Peter Morris [Droopy eyes software], Feb 7, 2005, in forum: ASP .Net
    Replies:
    0
    Views:
    577
    Peter Morris [Droopy eyes software]
    Feb 7, 2005
  3. =?Utf-8?B?TXJGZXo=?=

    Child window property window.opener null after postback

    =?Utf-8?B?TXJGZXo=?=, Apr 28, 2005, in forum: ASP .Net
    Replies:
    1
    Views:
    5,676
    =?Utf-8?B?TXJGZXo=?=
    Apr 28, 2005
  4. MrFez
    Replies:
    1
    Views:
    213
    Yunus Emre ALPĂ–ZEN [MCP]
    Apr 28, 2005
  5. window.opener, form.opener?

    , Jul 14, 2006, in forum: Javascript
    Replies:
    5
    Views:
    283
Loading...

Share This Page