Skip to main content
Participant
February 7, 2009
Question

cfcontent and close page

  • February 7, 2009
  • 1 reply
  • 499 views
Hi,

When I want to download a document, I use the cftag cfcontent ...
My problem is this one : when the document is open, I would like to close the windows that open the document with cfcontent.

I have try many thinks, but nothing work !

1) <script>window.close()</script>
2) <BODY onLoad="setTimeout(window.close, 30000)">

Code :

<html>
<head>
<title>test</title>
<cfheader name="Content-Disposition" value="attachment; filename=#doc_p#">

<cfswitch expression="#type_doc#">
<cfcase value="doc"><cfset type_p = "application/msword"></cfcase>
<cfcase value="xls"><cfset type_p = "application/msexcel"></cfcase>
<cfcase value="pdf"><cfset type_p = "application/pdf"></cfcase>
<cfcase value="rtf"><cfset type_p = "application/rtf"></cfcase>
<cfcase value="txt"><cfset type_p = "text/plain"></cfcase>
<cfcase value="gif"><cfset type_p = "image/gif"></cfcase>
<cfcase value="jpg"><cfset type_p = "image/jpeg"></cfcase>
<cfcase value="tml"><cfset type_p = "text/html"></cfcase>
<cfcase value="html"><cfset type_p = "text/html"></cfcase>
<cfcase value="htm"><cfset type_p = "text/html"></cfcase>
<cfdefaultcase>
<cfset type_p = "Application/Unknown">
</cfdefaultcase>
</cfswitch>

<cfswitch expression="#type_doc2#">
<cfcase value="docx"><cfset type_p = "application/msword"></cfcase>
<cfcase value="xlsx"><cfset type_p = "application/msexcel"></cfcase>
</cfswitch>
</head>
<body>
<cfcontent file="#chemin_fichier#documents\#dir_p#\#doc_p#" type="#type_p#">

<script>
window.close();
</script>

</body>
</html>



If somebody have a solution.

Thanks you.

Dave
This topic has been closed for replies.

1 reply

Inspiring
February 11, 2009
dave_75 wrote:
> Hi,
>
> When I want to download a document, I use the cftag cfcontent ...
> My problem is this one : when the document is open, I would like to close the
> windows that open the document with cfcontent.

Open the document in a new window. The browser will close the window
automatically if the user is downloading the file.

--
Mack