Results 1 to 8 of 8

Thread: Refresh Parent window on close of Popup window

  1. #1
    Join Date
    Sep 2011
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Refresh Parent window on close of Popup window

    1) Script Title: DHTML WINDOW WIDGET(v1.1)

    2) Script URL (on DD): http://www.dynamicdrive.com/dynamici...ndow/index.htm

    3) Describe problem:

    The Popup window is working perfect as I want in my ASP.Net page
    I want to refresh Parent window on close of the Popup.

    _dopostBack is also working but, I need to refresh the whole page as Popup window is adding/removing run time Textbox in parent window.

    As the code is using iframe to generate popup window.opener is not working.

  2. #2
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,495
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    If I understand you correctly:

    Code:
    window.opener.parent.location.reload();
    Or possibly:

    Code:
    parent.location.reload();
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

  3. #3
    Join Date
    Sep 2011
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Hi John

    I have tried all those

    window.opener.location.reload()
    and also
    parent.location.relaod()

    window.opener.location.href='"default.aspx"

    but those all not working get the error message

    window.opener is null or not ab object

    same for all if change to parent.location

  4. #4
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,495
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    Then I would have to see the page.

    Please post a link to a page on your site that contains the problematic code so we can check it out.
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

  5. #5
    Join Date
    Sep 2011
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Hi John

    the script is dhtmlmodal.htm

    http://www.dynamicdrive.com/dynamici...dhtmlmodal.htm

    the page is running for local Intranet and behind the firewall so cant link here.

    Any way I have tested the simple java code to open popup window, with that
    window.opener.location.reload() is working perfectly.

    but when I call dhtmlwindow.open

    call the below function in Button_onclcik()
    here some code to save data in database.

    response.write("<script>window.opener.location.reload();</script>");
    response.write("<script> parent.emailwindow.hide();</script>");

    its not working and get error window.opener is null or not an object

  6. #6
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,495
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    Does the emailwindow load onload of the parent window? If so reloading the parent will reload the emailwindow. If not, reloading the parent will have the effect of dismissing the emailwindow. It won't be there any longer because it depends upon the parent to exist. If the former, you will have to rethink your approach. If the latter, and the emailwindow is in fact an iframe, and it's page is on the same domain as the parent, all you need is:

    Code:
     response.write("<script>parent.window.location.reload();</script>");
    However, just writing out a script like that to a page might not bring the desired result anyway. It has to execute. But from what you're saying, from the error you're getting, it sounds like it is executing.
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

  7. #7
    Join Date
    Sep 2011
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Hi John,

    Here is the code which I use
    <script type="text/javascript">
    function openaddproject() {
    addprojwindow = dhtmlmodal.open('ProjBox', 'iframe', 'AddProject.aspx', 'Add Project with Job/MM/MS Code', 'width=750px,height=500px,center=1,resize=0,scrolling=0')
    addprojwindow.onclose = function() { //Define custom code to run when window is closed
    var theform = this.contentDoc.forms[0] //Access first form inside iframe just for your reference
    return true

    }
    }

    </script>

    calling the function through hyperlink.

    <a href="#" onClick="openaddproject(); return true"><span class="bluelink1">Add Project</a> </span><span id="addproject" style="color: red"></span>


    Now at the Button click event which first save the data at end i have this code

    Response.Write("<script>window.opener.location.reload();</script>");
    Response.Write("<script>parent.addprojwindow.hide();</script>");
    Response.Write("<script>parent.addprojwindow.close();</script>");

  8. #8
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,495
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    Change this:

    Code:
     Response.Write("<script>window.opener.location.reload();</script>");
     Response.Write("<script>parent.addprojwindow.hide();</script>");
     Response.Write("<script>parent.addprojwindow.close();</script>");
    to:

    Code:
     Response.Write("<script>parent.window.location.reload();</script>");
    That should at least reload the top page. If you still need those others, then they have to be done first:

    Code:
     Response.Write("<script>parent.addprojwindow.hide();</script>");
     Response.Write("<script>parent.addprojwindow.close();</script>");
     Response.Write("<script>parent.window.location.reload();</script>");
    I'm just going by your word that you get an error, which should mean that the code is actually getting executed, or is attempting to execute.

    If you want more help:

    Please post a link to a page on your site that contains the problematic code so we can check it out.
    Last edited by jscheuer1; 09-05-2011 at 05:05 PM. Reason: add - I'm just going by . . .
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •