PDA

View Full Version : Nesting modal windows



jrootham
12-22-2008, 06:33 PM
1) Script Title: DHTML Modal window v1.1

2) Script URL (on DD): http://www.dynamicdrive.com/dynamicindex8/dhtmlwindow/dhtmlmodal.htm

3) Describe problem:
My site: http://www.genuinesigns.com/modal/docroot/editor.php

I would like to nest modal windows. I would like to have a button on one modal window that opens another modal window and when the second window closes the first one is displayed.

Is this possible? It does not seem to work in the obvious way.

ddadmin
12-22-2008, 10:42 PM
I would like to have a button on one modal window that opens another modal window and when the second window closes the first one is displayed.

I gather you simply mean a button within one modal window that opens another modal window in the same web page, not inside the former window (hence nested)? In other words, open multiple modal windows at the same time.

jrootham
12-22-2008, 11:18 PM
Yes. Multiple modal windows but only one active at a time. To the user it should appear like a stack.

ddadmin
12-23-2008, 08:22 AM
Well, opening multiple modal windows by itself is supported by the script. The windows would appear on top of one another, stacked. Just call dhtmlmodal.open() for each instance of a window you wish to open. So in your case, lets say you have the following code to open the very first modal window:


var agreewin=dhtmlmodal.open("agreebox", "iframe", "agreement.htm", "This Page's Terms of service", "width=590px,height=450px,center=1,resize=1,scrolling=0", "recal")


Now, inside agreement.htm, you wish to show a link that opens another modal window. Such a link on that page would look like:


<!--This code appears in agreement.htm-->

<script type="text/javascript">

function modal2(){
confirmwin=parent.dhtmlmodal.open("confirmbox", "iframe", "confirm.htm", "Confirmation Window", "width=300px,height=400px,center=1,resize=1,scrolling=0", "recal")
}

</script>

<a href="javascript:modal2()">Open Confirmation Window</a>

Notice the ".parent" code in red- this is required when calling dhtmlmodal.open() on the parent page from the IFRAME page (both pages must be from the same domain). Also, notice the two variables in bold- these must be arbitrary, but unique variable names for each instance of a modal window on your page. In other words, don't use the same variable name when invoking another modal window.

jrootham
12-30-2008, 04:20 PM
Thanks very much for your reply. I have been explaining myself badly.

I can open windows from buttons on prior windows, but when I close that window the prior window is also closed.

I am using a slightly different method to get a pointer to the javascript on the parent page. It does call the the correct functions so I don't think that is the problem.

I had a theory that the onclose function for the nested window was causing the problem, but when I removed it the problem persists.

jrootham
12-31-2008, 04:33 PM
I found my silly bugs causing this problem, thanks.