PDA

View Full Version : Can't close DHTML Window Widget (??)



Mike2000
09-12-2008, 11:12 PM
1) Script Title: DHTML Window widget (v1.1)

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

3) Describe problem:
I can open a window from a given page and populate it, but I can't seem to call the close() or hide() property from the opened window. I can call it from the "original" window, but nothing I do will allow me to close the window *from* the opened window.

For example, say I've opened a window named "wizbox".

I've tried:
"wizbox.close() ", "window.opener.wizbox.close()", and ""window.opener.wizbox.hide()" from the popup window to no effect.

What I'm doing is loading an entry form into the popup window...when the user submits the form I'd like to have the form get submitted and the widow be hidden or closed (either is fine).

Here's how I'm opening the window:


<script type="text/javascript">
function openmypage(){
wizwin=dhtmlwindow.open("wizbox", "iframe", "/trkwizard.htm", "Form Wizard", "width=590px,height=350px,resize=1,scrolling=1,center=1");
}
</script>

I then open this window with a button:

<input type="button" value="Form Wizard" onClick="openmypage(); return false">

It opens fine, and I can close the popup window from the original 'base' window by doing either "onClick='wizwin.hide();' OR onClick='wizbox.hide();' (It seems like only one should work, but heck if I know...) but I cannot seem to close it from the popup window itself.

I really, really, really want to use this script. What am I missing, or doing wrong?

:confused:

Nile
09-12-2008, 11:25 PM
Try this:


<script type="text/javascript">
var wizwin = "null"; //make it global
function openmypage(){
wizwin=dhtmlwindow.open("wizbox", "iframe", "/trkwizard.htm", "Form Wizard", "width=590px,height=350px,resize=1,scrolling=1,center=1");
}
</script>

Mike2000
09-13-2008, 12:31 AM
I made the change as suggested:


<script type="text/javascript">
var wizwin = "null"; //make it global
function openmypage(){
wizwin=dhtmlwindow.open("wizbox", "iframe", "$web_path/trkwizard.htm", "Tracker Wizard", "width=590px,height=350px,resize=1,scrolling=1,center=1");
}
</script>

But, nope, still no go. What should I be calling from the popup page:

wizwin.hide();

or

window.opener.wizwin.hide();

or something else?? (I can post more of the code if necessary.)

ddadmin
09-13-2008, 01:19 AM
Assuming you've opened a window from your main page using the code:


wizwin=dhtmlwindow.open("wizbox", "iframe", "/trkwizard.htm", "Form Wizard", "width=590px,height=350px,resize=1,scrolling=1,center=1");

To close this window from within "wizbox", or (trkwizard.htm), the code would be:


parent.wizwin.close()

Mike2000
09-13-2008, 12:51 PM
Thank you very much! That did the trick.