views:

946

answers:

3

Modern browsers have multi-tab interface, but JavaScript function window.showModalDialog() creates a modal dialog that blocks all of the tabs.

I'd like to know if there is a way to create a modal dialog that blocks only the tab it's been created in?

+8  A: 

You could use one of the more 'Ajax-like' modal dialogs, which are just absolute positioned divs, floating on top of everything else.

Those are modal to the 'document' and not the browser.

For instance take a look it this jQuery plugin

P.S. showModalDialog() is an IE only call, so you might want to not use that altogether.

Michiel Overeem
How come it works in FF?
z-boss
Mmm, funny, all sites report that it isn't supported. Do you have a life example?
Michiel Overeem
actually Firefox (3 at least) does implement the showModalDialog() method. Not sure since when... but agreed the abs. pos. div is a better choice.
scunliffe
z-boss
@sneg: ohhh, didn't know that FF3 added support for that...
Michiel Overeem
+2  A: 

Nope. It's conceivable IE8's ‘loose coupling’ might behave like this at some point, but it doesn't in the current betas.

I second Michiel's recommendation. A pseudo-modal-dialogue working by obscuring the rest of the page, floating a div on top, and calling the script back when it's finished, is both:

  • much more usable/less annoying than a real modal dialog
  • compatible with any browser

showModalDialog/showModelessDialog themselves are generally to be avoided.

bobince
A: 

Firefox 3 supports https://developer.mozilla.org/en/DOM/window.showModalDialog (but it also blocks all tabs)