cfdeveloper
Programmer
Hi Guys, I'm hoping someone can help me. I've tried everything but can't quiet nail this problem. I have this page that has a hyper-link. Clicking on the hyper-link opens up a pop-up window. The url looks something
like this:
window.open('attachment.cfm?promptUser=true&id=12345&filename=testfile', 'Attachment', 'top=10,left=10,height=315,width=600,resizable=Yes,scrollbars=Yes');
You may have noticed I'm passing a url variable 'promptUser' with a default value of 'true'.
Here is the code in the pop-up window.
<script language="javascript">
function openAttachment(){
window.location = "<cfoutput>#cgi.SCRIPT_NAME#?FILENAME=#url.FILENAME#&ID=#url.id#&promptUser=false</cfoutput>";
}
function cancelAttachment(){
window.close();
}
</script>
<!--- if the url variable promptUser is true, display few instructions to help
the user to decide what he must be doing --->
<cfif isDefined("url.promptUser") and promptUser eq "true">
<table width="100%" border="0" cellspacing="0" cellpadding="5">
<tr>
<td>
If you intend to modify an existing attachment, you must follow the below steps:
<br>
blah blah blah
</td>
</tr>
<tr>
<td valign="top" align="center">
<img src="Images/okbutt.gif" id="okbutt" name="okbutt" border="0" alt="open attachment" onclick="openAttachment()">
<br>
</td>
<td valign="top" align="center">
<img src="Images/cancelbutt.gif" id="cancelbutt" name="cancelbutt" border="0" alt="close" onClick="cancelAttachment()">
<br>
</td>
</tr>
</table>
<!--- if it is false, just open the attachment in its own application --->
<cfelseif url.promptUser eq "false">
<cfset fName = url.filename>
<!--- Generates custom HTTP response headers to return to the client. --->
<CFHEADER NAME="Content-Type" VALUE="application/unknown">
<CFHEADER NAME="Content-Disposition" VALUE="attachment; filename=#fName#">
<CFCONTENT TYPE="application/unknown" FILE="UploadFolder\#fName#" deletefile="no">
</cfif>
I hope the above code is self-explainatory. If you notice, I'm setting 'promptUser' url variable to 'false' in the 'openAttachment' function. This opens up the file open/save dialog box.
Now then, this is where I'm stuck. I want to close the pop-up window when the 'promptUser' value is 'false', in other words when the user clicks on the 'okbutt' button. Can someone show me how to do this.
I would really appreciate your help
Best regards,
cfcoder
like this:
window.open('attachment.cfm?promptUser=true&id=12345&filename=testfile', 'Attachment', 'top=10,left=10,height=315,width=600,resizable=Yes,scrollbars=Yes');
You may have noticed I'm passing a url variable 'promptUser' with a default value of 'true'.
Here is the code in the pop-up window.
<script language="javascript">
function openAttachment(){
window.location = "<cfoutput>#cgi.SCRIPT_NAME#?FILENAME=#url.FILENAME#&ID=#url.id#&promptUser=false</cfoutput>";
}
function cancelAttachment(){
window.close();
}
</script>
<!--- if the url variable promptUser is true, display few instructions to help
the user to decide what he must be doing --->
<cfif isDefined("url.promptUser") and promptUser eq "true">
<table width="100%" border="0" cellspacing="0" cellpadding="5">
<tr>
<td>
If you intend to modify an existing attachment, you must follow the below steps:
<br>
blah blah blah
</td>
</tr>
<tr>
<td valign="top" align="center">
<img src="Images/okbutt.gif" id="okbutt" name="okbutt" border="0" alt="open attachment" onclick="openAttachment()">
<br>
</td>
<td valign="top" align="center">
<img src="Images/cancelbutt.gif" id="cancelbutt" name="cancelbutt" border="0" alt="close" onClick="cancelAttachment()">
<br>
</td>
</tr>
</table>
<!--- if it is false, just open the attachment in its own application --->
<cfelseif url.promptUser eq "false">
<cfset fName = url.filename>
<!--- Generates custom HTTP response headers to return to the client. --->
<CFHEADER NAME="Content-Type" VALUE="application/unknown">
<CFHEADER NAME="Content-Disposition" VALUE="attachment; filename=#fName#">
<CFCONTENT TYPE="application/unknown" FILE="UploadFolder\#fName#" deletefile="no">
</cfif>
I hope the above code is self-explainatory. If you notice, I'm setting 'promptUser' url variable to 'false' in the 'openAttachment' function. This opens up the file open/save dialog box.
Now then, this is where I'm stuck. I want to close the pop-up window when the 'promptUser' value is 'false', in other words when the user clicks on the 'okbutt' button. Can someone show me how to do this.
I would really appreciate your help
Best regards,
cfcoder