Javascript ShowModalDialog return info to the parent

Posted on 2006-05-11
Last Modified: 2008-01-09

This should be an easy answer for you to answer.  but it is urgent so I am going to give 500 points.

I would like to use the ShowModalDialog for returning information to the parent window.  Is this possible?  I did come across the following statement:

myReturnValue = showModalDialog('template.html',[calen,self],boxFeatures);

but the description says that the box uses script template from the parent???

would it also send back the contents of a form field?

does anyone have any ideas as to how this would work?

I do have another question and that is the parameters for the showmodal is URL, Arguments, boxfeatures
I read on the microsoft web-site that the arguments can be used for sending objects, why couldn't you send a complete web-page as an argument?

can you please provide examples?

Thanks very much in advance

Question by:ralphsauto
    LVL 17

    Accepted Solution

    try this

    Inside parent page:

    function openModal(){
     var retVal=showModalDialog('a.html','Passing this Vlaue','dialog window properties');
     alert('modal returned value="'+retVal+'"');
    <input type="button" value=" Open Modal" onclick="openModal()"/>

    Inside a.html (modal window) page:
    function getInfoFromParent(){
    var PassedString = window.dialogArguments;
    document.getElementById("fromParent").innerText = PassedString;
    return value="from child";

    <body onload="getInfoFromParent();">
    <span id="fromParent"></span>

    Author Comment

    Sorry, got my answer and forgot to award the points

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    How to improve team productivity

    Quip adds documents, spreadsheets, and tasklists to your Slack experience
    - Elevate ideas to Quip docs
    - Share Quip docs in Slack
    - Get notified of changes to your docs
    - Available on iOS/Android/Desktop/Web
    - Online/Offline

    A common challenge, or question, when working with two calendar dates is: What is the difference between the specified days? As is frequently the case, the answer is: It depends... What kind of difference do you want? Given two date obje…
    "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…
    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…

    794 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