09 March 2011

window.showModalDialog() - Cross Browser, new version

Hello,

This is a continuation, or a new version for my last post about window.showModalDialog().

The new version was implemented as a jQuery function to which you can pass options which you like.
This version was made because:
    1) The impossibility of previous version to retain dialogArguments during postback;
    2) The impossibility of previous version to close the dialog when the target page is inside several iframe tags;
    3) The impossibility of previous version to retain window.returnValue during postback;
    4) It will be possible now to fire a postback of the page or to fire a postback of a element (with targetElementId) right after the dialog was closed and the callback function finished to execute;
    5) Theoretically this popup library can be used to open another popup inside an existing one (Note: I haven't tried this yet).

However, previous version of my showModalDialog can satisfy someone's requirements and it will be no need to complicate his life with the new version.

IE window.showModalDialog() - Cross Browser solution

Hello,

QUESTION: How to make window.showModalDialog() work on cross browser? or at least how to do something similar? with arguments, return value and window.close()?

ANSWER: There is no simple way to do that.

ATTENTION: dialogArguments will be lost if the page inside the popup will do a postback. For a better solution see my new version - click here.

First of all window.showModalDialog() function is something which works only on Internet Explorer and in the best case this command will open a new small window on some browsers, however this window is far from a modal window.

If you still need to have the same functionality as window.showModalDialog(), to pass some parameters / arguments to the page inside the popup and then return some values back from that page in the parent page, and also have the ability to close the popup from the inside of the popup then this article is for you.

Here I have created a modal popup, using jQuery, which gives you the ability to pass arguments to the page inside the popup almost in the same way as you would pass it through showModalDialog().

Need more? Leave comments and subscribe to my blog.

.