How do I change the opening page if the dialog box was opened with shoModalDialog?

Posted on 2007-10-15
Last Modified: 2009-12-16
If i opened a window with, window.showModalDialog, how can I tell what the name of the window is that opened the Dialog box and how do I reload the opening page with a new page, close the dialog and show the new opening page.

For example if I opened with I could use window.opener.location.href; so in the same manner is there a way to reset the opening page if the page was opened with window.showModalDialog.

I have scanned the web, and so far I found that after the call to the window.showModalDialog I can add the following line of code to force the refresh of the page.  This is not exactly what I asked for, but at the top of the page
I can then redirect to the page I want.  The showModaldialog does not allow refresh of parent page until the Dialog box is closed.  
window.location = window.location;

Let me know if you have any comments on it.  

language javascript:
Question by:swansonplace
    LVL 75

    Accepted Solution

    showModalDialog is designed to have a page open a window and have that window return a value.

    If you handle everything in the page that opens the dialog, you are just fine.

    var url2Load=showModalDialog(....)
    if (url2Load !="") location = url2Load;

    and in the modalDialog do


    Alternative is showModelessDialog:
    LVL 75

    Assisted Solution

    by:Michel Plungjan
    to just reload:

    var reloadPage=showModalDialog(....)
    if (reloadPage) location.reload(1);

    and in the showModal have


    to reload and


    to just close and not reload

    Author Comment

    Thank you.

    Featured Post

    How your wiki can always stay up-to-date

    Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
    - Increase transparency
    - Onboard new hires faster
    - Access from mobile/offline

    Join & Write a Comment

    "That which we persist in doing becomes easier, not that the task itself has become easier, but that our ability to perform it has improved." Ralph Waldo Emerson Introduction: One of the wonderful things about the web is that it makes it s…
    Having worked on larger scale sites, we found out that you are bound to look at more scalable solutions to integrating widgets, code snippets or complete applications and mesh them into functional sites, in any given composition. To share some of…
    The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
    The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

    746 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    14 Experts available now in Live!

    Get 1:1 Help Now