PDA

View Full Version : No closing the wondows



artonlinehome
09-20-2010, 09:10 AM
I am trying to open modal using

I got code fom
http://www.dynamicdrive.com/dynamicindex8/dhtmlwindow/dhtmlmodal.htm


var test123=dhtmlmodal.open("agreebox", "iframe", "location.do?method=selectlocation&readPreview=3", "This Page's Terms of service", "width=590px,height=450px,center=1,resize=1,scrolling=0");

test123.onclose=function(){
// need to do some operation
}
}
and popup jsp page on click of one button trying to close the popup like
parent.test123.hide();

but in popup window it is saying test123 is undefind.

Please help me on this.

jscheuer1
09-20-2010, 11:17 AM
Your code snippet has an extra closing brace:



var test123=dhtmlmodal.open("agreebox", "iframe", "location.do?method=selectlocation&readPreview=3", "This Page's Terms of service", "width=590px,height=450px,center=1,resize=1,scrolling=0");

test123.onclose=function(){
// need to do some operation
}
}

This implies that it's part of a function, perhaps even an onload function.

In any case, if that brace were there without its being part of a function, it would cause a fatal scripting error and the modal wouldn't even load.

So that means that you are declaring test123 in a limited scope, one not available by doing parent.anything from the iframe.

You need to get it out of that function, or declare the variable globally. The latter would be easier:


window.test123=dhtmlmodal.open("agreebox", "iframe", "location.do?method=selectlocation&readPreview=3", "This Page's Terms of service", "width=590px,height=450px,center=1,resize=1,scrolling=0");

test123.onclose=function(){
// need to do some operation
}
}

If you want more help:

Please post a link to a page on your site that contains the problematic code so we can check it out.