Javascript synchronous Yes-No-Cancel dialog [modified]
-
Hello everyone! I'm implementing a javascript function that must show a modal dialog with Yes-No-Cancel buttons and return the selected value. I have found a workaround for IE, Firefox, Chrome and Safari (using
window.showModalDialog
). Does anyone know any solution for Opera? It doesn't supportshowModalDialog
:mad: Or, as a variant, maybe there's any implementation of noop for Opera? (non CPU-intensive loop) The problem is that I can't show a modal dialog in such way:show(success: function() { ... });
My function is called from external javascript component, and this component is expecting the result in synchronous way. Thanks in advance.
Die Energie der Welt ist konstant. Die Entropie der Welt strebt einem Maximum zu.
modified on Friday, June 18, 2010 4:02 PM
-
Hello everyone! I'm implementing a javascript function that must show a modal dialog with Yes-No-Cancel buttons and return the selected value. I have found a workaround for IE, Firefox, Chrome and Safari (using
window.showModalDialog
). Does anyone know any solution for Opera? It doesn't supportshowModalDialog
:mad: Or, as a variant, maybe there's any implementation of noop for Opera? (non CPU-intensive loop) The problem is that I can't show a modal dialog in such way:show(success: function() { ... });
My function is called from external javascript component, and this component is expecting the result in synchronous way. Thanks in advance.
Die Energie der Welt ist konstant. Die Entropie der Welt strebt einem Maximum zu.
modified on Friday, June 18, 2010 4:02 PM
showModalDialog is not part of any web standard. I would look into the way that the AJAXControlToolkit ModalPopupExtender does it by showing a div with a high z-index that covers the page and captures any events that would normally go to the items behind it. And noop usually means "no op" i.e. no operation performed/do nothing and has nothing to do with loops.
-
showModalDialog is not part of any web standard. I would look into the way that the AJAXControlToolkit ModalPopupExtender does it by showing a div with a high z-index that covers the page and captures any events that would normally go to the items behind it. And noop usually means "no op" i.e. no operation performed/do nothing and has nothing to do with loops.
Yeah, you are right, showModalDialog is not a part of any web standard but it's supported by all web browsers. Furthermore, Opera tells this:
typeof(window.showModalDialog)
will be"function"
But I don't understand how to use it in Opera Using a div with high z-index will be not acceptable because it will not allow to wait while the user clicks on it. Yeah, I know how to implement everything using div-s but the problem is that my function must be called from external JS-component and return the ansewer to it. The component's code cannot be changed. Yeah, I mean exactly non cpu-intensive no-operation, if it exists, this means that non cpu-intensive loop can be easily implemented. Please sorry me for inaccuracy.Die Energie der Welt ist konstant. Die Entropie der Welt strebt einem Maximum zu.
-
Hello everyone! I'm implementing a javascript function that must show a modal dialog with Yes-No-Cancel buttons and return the selected value. I have found a workaround for IE, Firefox, Chrome and Safari (using
window.showModalDialog
). Does anyone know any solution for Opera? It doesn't supportshowModalDialog
:mad: Or, as a variant, maybe there's any implementation of noop for Opera? (non CPU-intensive loop) The problem is that I can't show a modal dialog in such way:show(success: function() { ... });
My function is called from external javascript component, and this component is expecting the result in synchronous way. Thanks in advance.
Die Energie der Welt ist konstant. Die Entropie der Welt strebt einem Maximum zu.
modified on Friday, June 18, 2010 4:02 PM
http://www.ericmmartin.com/projects/simplemodal-demos[^] try to use jquery. it will take just a single line of code to show a dialog box... after including its js file. if you want to do it of your own then you need to compromise all the web browsers and this will be taken care by jquery. a javascript frame work. of if you want to do it of your own... ready about z-index and opacity... the gimmick is display a transparent div with 100% height and 100% width with the z-index more than any existing element. for example this overlay div will have zindex as 95. then display your rectangle dialog which will contain all three buttons above the overlay div with zindex more than 95. now try to click apart from the dialog rectangle( on any hyperlinks). nothing happens. the overlay div receives the mouse clicks because it has occupied the complete screen. once you click any button in the dialog then make the overlay div to display none and hide the rectangle. the above link is just an example. use the last one. and there are more than this in the web... so chose the one which will suite your design. and here is another use full link... http://jquery.malsup.com/block/#demos[^] you can search the web like "jquery modal dialog" and try to use your own words...
Today's Beautiful Moments are Tomorrow's Beautiful Memories
-
http://www.ericmmartin.com/projects/simplemodal-demos[^] try to use jquery. it will take just a single line of code to show a dialog box... after including its js file. if you want to do it of your own then you need to compromise all the web browsers and this will be taken care by jquery. a javascript frame work. of if you want to do it of your own... ready about z-index and opacity... the gimmick is display a transparent div with 100% height and 100% width with the z-index more than any existing element. for example this overlay div will have zindex as 95. then display your rectangle dialog which will contain all three buttons above the overlay div with zindex more than 95. now try to click apart from the dialog rectangle( on any hyperlinks). nothing happens. the overlay div receives the mouse clicks because it has occupied the complete screen. once you click any button in the dialog then make the overlay div to display none and hide the rectangle. the above link is just an example. use the last one. and there are more than this in the web... so chose the one which will suite your design. and here is another use full link... http://jquery.malsup.com/block/#demos[^] you can search the web like "jquery modal dialog" and try to use your own words...
Today's Beautiful Moments are Tomorrow's Beautiful Memories
Thanks.. But it's not what I'm searching for :( It's modal but not synchronous. The key moment is that using this library, I cannot wait until the dialog is closed, like in:
alert("test"); ... // will be executed after user clicks OK
Die Energie der Welt ist konstant. Die Entropie der Welt strebt einem Maximum zu.
-
http://www.ericmmartin.com/projects/simplemodal-demos[^] try to use jquery. it will take just a single line of code to show a dialog box... after including its js file. if you want to do it of your own then you need to compromise all the web browsers and this will be taken care by jquery. a javascript frame work. of if you want to do it of your own... ready about z-index and opacity... the gimmick is display a transparent div with 100% height and 100% width with the z-index more than any existing element. for example this overlay div will have zindex as 95. then display your rectangle dialog which will contain all three buttons above the overlay div with zindex more than 95. now try to click apart from the dialog rectangle( on any hyperlinks). nothing happens. the overlay div receives the mouse clicks because it has occupied the complete screen. once you click any button in the dialog then make the overlay div to display none and hide the rectangle. the above link is just an example. use the last one. and there are more than this in the web... so chose the one which will suite your design. and here is another use full link... http://jquery.malsup.com/block/#demos[^] you can search the web like "jquery modal dialog" and try to use your own words...
Today's Beautiful Moments are Tomorrow's Beautiful Memories