0

We have a big enterprise application that use window.showModalDialog to display modal windows. We used them at lots of places to show dialog messages and child forms. Now we want to support all the browsers, because in Chrome window.showModalDialog does not display modal dialog, we are thinking of using overlays div over the content and then display top window with div using higher z-index. It works beautifully, But following is the big problem we are facing - 1. Most of code use the following syntax -

var return = window.showModalDialog();
doSomethingWithReturnValue(return);

method to display modalDialog, now the code will not execute and wait for user to close the window the then the next line of code doSomethingWithReturn() method will execute, This code in used at atleast hundards of places in the code. There there is way in javascript to replace window.showModalDialog() with something like follows -

var return = showDialogWindow() // this will use overlays and div with higher index to // display the content

Our problem is that showDialogWindow() will return immediately and all the code will execute without waiting for user to close the window. Alternative will be to use callback, but then results will be to change the whole code around and more testing and potential for more bugs.

Is there way design showDialogWindow() in such a way that showDialogWidnow will wait as long as user have not close the top div.

Thanks, If you have more questions please let me know.

daljit
  • 1,256
  • 1
  • 11
  • 30
  • document.body.onclick=function(){ alert(window.showModalDialog("http://google.com/", [1,2,3])); } worked in chrome for me... – dandavis May 01 '13 at 19:03
  • Yes, it works but window is not modal, you can still interact with the parent window. Thanks – daljit May 01 '13 at 19:06
  • fair enough, but you can simply paste an opaque fixed position div over the page before you launch the modal to prevent interaction until the modal closes and the overlay div is removed. Almost the same thing as other browsers, and without re-factoring 100s of functions. you can even re-wrap window.showModalDialog() in chrome to automatically add/remove the overlay for you when it's called. – dandavis May 01 '13 at 19:40
  • Thanks dandavis, I did think about the same thing, but manager did not think it is solution as user can minimize the window and user can close the main window and could ignore the child window. Thanks for suggestions. – daljit May 01 '13 at 20:01

0 Answers0