tags:

views:

1749

answers:

2

What are situation when you want to use window.showModalDialog function? It seams that you can do exactly the same with window.open function and few parameters that remove some of the chrome (navigation, addressbar, etc...)

When would you want to use window.showModalDialog and window.open?

+5  A: 

Modal dialogs are dialogs that once opened by the parent, do not allow you to focus on the parent until the dialog is closed.

One could use a modal dialog for a login form, edit form, etc where you want to have a popup for user interaction but not allow the user to return to the window that opened the popup.

As a side note, I believe only Internet Explorer implementes window.showModalDialog, so that kind of limits your usage of it.

Samuel
FF3 finally has it. Chrome does too but I don't think it's truly modal there (can click behind it).
Crescent Fresh
a parameter to window.open can make it modal
geowa4
According to https://developer.mozilla.org/en/window.open: modal: Starting with Mozilla 1.2.1, this feature requires the UniversalBrowserWrite privilege. Without this privilege, it is ignored.
Grant Wagner
Firefox 3 note: The MSIE 6 equivalent to this feature is the showModalDialog() method. For compatibility reasons, it is now also supported in Firefox 3.
Grant Wagner
+1  A: 

Note that there's a bug in Chrome 2 which prevents showModalDialog() from loading properly. The popup window appears, but the content never loads.

One more reason to avoid using showModalDialog().

Jonathan