关闭使用iframe的cfwindow

问题描述:

问题:在表单提交之后关闭和销毁cfwindow的代码 - 要更改为使用iFrame(以适应文件上载)的HAD。现在“关闭”不起作用。关闭使用iframe的cfwindow

如何关闭一个包含iframe的cfwindow ...一旦iframe表单被提交????

流量:

基地页面 - >打开窗口

窗口包含IFRAME; IFRAME - >调用表单页面

表单页面 - >提交的操作页面(同一页)

操作页面 - >上传文件并执行其他形式的处理 - 关闭窗口。

=====

注:我已经减少了代码的精华 - 为了阅读方便......如果JS的块需要(或“应当”)去其他地方以及在某些引用另一种方式 - 请让我知道...

基本页 - basePage.cfm:

<script> 
    function launchWin(name,url) { 
     ColdFusion.Window.create(name+'_formWindow', name, url, 
    { height:500, 
     width:500, 
     modal:true, 
     closable:true, 
     draggable:true, 
     resizable:true, 
     center:true, 
     initshow:true, 
     minheight:200, 
     minwidth:200 
    }) 
} 
</script> 
<a href="javascript:launchWin('Attachment', 'iframe.cfm?id=101');" >ATTACH</a> 
<DIV ID="myContent"></div> 

====================== =====================

WINDOW PAGE - iframe.cfm - (iframe):

<iframe src="attachment.cfm?id=101"></iframe> 

===========================================

IFRAME SRC - attachment.cfm(注意 - 此代码工作B4把它在iframe):

<script> 
ColdFusion.Window.onHide('Attachment_formWindow', cleanup); 
function cleanup() { 
    ColdFusion.Window.destroy('Attachment_formWindow', true); 
} 
</script> 


<!--- HANDLE THE FORM ---> 
<cfif structKeyExists(FORM, 'add_Attachment') > 
    <!--- Do CFFILE to handle file upload ---> 
    <cffile action="upload" 
      destination="C:\" 
      filefield="theFile" 
      nameconflict="makeunique"> 
    <!--- other form processing goes here (not relevant to question at hand) ---> 
    <!--- refresh the calling page, and close this window - destroy it so contents don't presist ---> 
    <script> 
     ColdFusion.navigate('basePage.cfm?', 'myContent'); 
     ColdFusion.Window.hide('Attachment_formWindow'); 
    </script>  
</cfif> 


<!--- form to get information ---> 
<cfform name="attachmentForm" enctype="multipart/form-data" > 
<table> 
    <tr><td>FILE:</td><td><cfinput type="file" name="theFile" size="40" /></td></tr> 
    <tr><td>TITLE:</td><td><cfinput type="text" name="name" value="" size="40" maxlength="100" /></td></tr> 
    <tr><td>DESCRIPTION:</td><td><cftextarea name="description" cols="40" rows="10"></cftextarea></td></tr> 
    <tr><td></td><td><cfinput type="submit" name="add_Attachment" value="Add" /></td></tr> 
</table> 
</cfform> 

当你移动代码的iframe,你必须改变在JavaScript中的引用来引用到parent.,因为iframe引入了自己的子上下文(vs.一个生活在原始环境中的div)。

试试这个:

<script> 
parent.ColdFusion.Window.onHide('Attachment_formWindow', cleanup); 
function cleanup() { 
    parent.ColdFusion.Window.destroy('Attachment_formWindow', true); 
} 
</script> 


<!--- HANDLE THE FORM ---> 
<cfif structKeyExists(FORM, 'add_Attachment') > 
    <!--- Do CFFILE to handle file upload ---> 
    <cffile action="upload" 
      destination="C:\" 
      filefield="theFile" 
      nameconflict="makeunique"> 
    <!--- other form processing goes here (not relevant to question at hand) ---> 
    <!--- refresh the calling page, and close this window - destroy it so contents don't presist ---> 
    <script> 
     parent.ColdFusion.navigate('basePage.cfm?', 'myContent'); 
     parent.ColdFusion.Window.hide('Attachment_formWindow'); 
    </script>  
</cfif> 


<!--- form to get information ---> 
<cfform name="attachmentForm" enctype="multipart/form-data" > 
<table> 
    <tr><td>FILE:</td><td><cfinput type="file" name="theFile" size="40" /></td></tr> 
    <tr><td>TITLE:</td><td><cfinput type="text" name="name" value="" size="40" maxlength="100" /></td></tr> 
    <tr><td>DESCRIPTION:</td><td><cftextarea name="description" cols="40" rows="10"></cftextarea></td></tr> 
    <tr><td></td><td><cfinput type="submit" name="add_Attachment" value="Add" /></td></tr> 
</table> 
</cfform> 
+0

感谢杰克 - 我可以发誓,我试过......但我必须失去了森林直通的树木。完美地工作,并且是我正在寻找的确切'简单'的答案。 – jpmyob 2012-02-09 13:59:33