Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How do I close the pop-up window - kindly help

Status
Not open for further replies.

cfdeveloper

Programmer
Nov 20, 2003
144
GB
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
 
this does the job.

function openAttachment(){
opener.location = "<cfoutput>#cgi.SCRIPT_NAME#?FILENAME=#url.FILENAME#&ID=#url.id#&promptUser=false</cfoutput>";
window.close();
}

Ta,
cfcoder
 
When you paste long code on tek tips, wrap it in TGML tag [ code] and [/ code] (without the spaces)

Anyway.. this should work..

Code:
<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">
    [b][red]<script>
      <!--
         window.close()
      -->
    </script>[/red][/b]
</cfif>

ALFII.com
---------------------
If this post answered or helped to answer your question, please reply with such so that forum members with a similar question will know to use this advice.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top