PDA

View Full Version : CLOSE ISSUE WHEN CONTENT NAME PASSED TO open() AS VARIABLE



xanvis
06-06-2008, 05:49 AM
1) Script Title: DHTML MODAL

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

3) Describe problem:

I wrote the modal open function to accept content as a variable - so that I can have different content in the same iframe. The problem is the parent.thismodalwindow.close() does not work when I pass the content name as variable. This is what I meant ...


<script type="text/javascript">
function openurlmodal(targetUrl, boxTitle){ //Define arbitrary function to run desired DHTML Window widget codes
var ajwin=dhtmlmodal.open("ajaxurlbox", "iframe", targetUrl, boxTitle, "width=650px,height=450px,center=1,resize=1,scrolling=1", "recal")
ajwin.onclose=function(){return true}
}

<a href='#' onClick='openurlmodal("modalfiles/externalFormClose.htm", "Html!!"); return false'>Test Value Passing 2 !!</a>
<br>

And this is the code in the referenced content


<input type="button" value="CLOSE" name="X2" onClick="parent.ajwin.hide()" />

But this does not work.

However in my open statement if I directly pass the content name in the open statement - the close button works


function openurlmodal(targetUrl, boxTitle){ //Define arbitrary function to run desired DHTML Window widget codes
var ajwin=dhtmlmodal.open("ajaxurlbox", "iframe", "modalfiles/externalForm.htm", boxTitle, "width=650px,height=450px,center=1,resize=1,scrolling=1", "recal")
ajwin.onclose=function(){return true}
}

rangana
06-06-2008, 06:11 AM
But, these are two different files:
modalfiles/externalForm.htm - closes
modalfiles/externalFormClose.htm - failed

Was that an issue in the first place?

xanvis
06-06-2008, 06:59 AM
It does not matter - which ever html is called by paasing the name a parameter - the close() fuction does not work from there.

It is only when the name is passed a absolute value - the close function works.



So when I open the window as


ajaxwin=dhtmlmodal.open("ajaxtextbox", "iframe", "modalfiles/externalFormClose.htm", ...

The close works ..

But if I do


ajwin=dhtmlmodal.open("ajaxurlbox", "iframe", targetUrl, ..

and pass the targetUrl like


<a href='#' onClick='openurlmodal("modalfiles/externalFormClose.htm", "Html!!")>opoen </a> ..

the close() does not work ..


I AM NOT TALKING ABOUT THE 'X' button - it is the close button that is coded inside the reference html (externalFormClose.htm) ...

xanvis
06-16-2008, 03:47 PM
Found the solution .. actually it is documented in the script home page ..

I was using 'var' before the window variable definition ..
e.g.

<script type="text/javascript">
function openurlmodal(targetUrl, boxTitle){ //Define arbitrary function to run desired DHTML Window widget codes
var ajwin=dhtmlmodal.open("ajaxurlbox", "iframe", targetUrl, boxTitle, "width=650px,height=450px,center=1,resize=1,scrolling=1", "recal")
ajwin.onclose=function(){return true}
}

solution is to drop the 'var'


<script type="text/javascript">
function openurlmodal(targetUrl, boxTitle){ //Define arbitrary function to run desired DHTML Window widget codes
ajwin=dhtmlmodal.open("ajaxurlbox", "iframe", targetUrl, boxTitle, "width=650px,height=450px,center=1,resize=1,scrolling=1", "recal")
ajwin.onclose=function(){return true}
}