Click to See Complete Forum and Search --> : Help with mime types.


utahsaint
03-07-2003, 10:13 AM
I need to prompt a user to download a file then gain control back to the parent, or refesh the page. I would write some examples of code but its all cold fusion that creates the header and mime types. I can add any JavaScript needed though. To explain what this is doing the form page calls an action page that has the mime type on it. After it calls that page all control is lost and only a save/open dialog appears. There is nothing special to the code this is all done with standard HTML mime type codes. But I can never refresh the page, or call any JS after the prompt.

HELP.

Nevermore
03-07-2003, 02:03 PM
To put the browser window in focus, use the focus() function.

utahsaint
03-07-2003, 04:43 PM
After the user clicks on save or cancel from the dialog box I need to refresh the parent window or call a function. I have seen in some places that they use javaScript on the page with the mime type. This however did not work for me. If it helps I can use an IE only impliemenation.

utahsaint
03-10-2003, 09:59 AM
I like the idea of setting up a timmer and kind of understand what you are saying. I wish I could post some code but its just a submit of a form. When the form submits the page it submits to has a mime type="text" or whatever it is IE exe so forth. It also uses the header and sets it to header name="Content-disposition" value="attachment;filename=fileName"

Using these values for the mime type/header will automticaly bring up the prompt for the download of the file. The bad thing is that I loose control of the page.

I have tried to use a target="_new" on the form but then I have two browser windows open and still can't refresh the parent window. The other idea was to use a js function that would do a window.open(dialog window); then refresh the parent window, and close this window. I had no luck there either and the bad part was that again I had two windows open. HELP.

utahsaint
03-10-2003, 11:45 AM
Okay sorry for the cold fusion in here but I figured out my answer. Here it is:

My parent window opens a window like this:

window.open('<cfoutput>/#APPLICATION.custom_tags_mapping#/file_control.cfm?docRef=#urlencodedformat(cgi.http_referer)#&file_and_path=#urlencodedformat(file_and_path)#&org_name=#org_name#&decrypt=true</cfoutput>&close=no&refresh=yes','file_control','scrollbars=no,status=no,title=no,width=10,height=10');

Then the child windows does the following:

<script language="JavaScript">
function refreshParent(){
opener.parent.document.location="<cfoutput>#docRef#</cfoutput>";
self.close();
}

<cfoutput>
opener.parent.document.location="#application.url#/custom_tags/fx_copy_file.cfm?decrypt=#url.decrypt#&file_and_path=#urlencodedformat(url.file_and_path)#&org_name=#url.org_name#";
</cfoutput>

<cfif refresh eq "yes">
setTimeout("refreshParent()",1000);
</cfif>
<cfif close eq "yes">
parent.window.close();
self.close();
</cfif>

</script>

So basicaly the child window acts as a controller for the parent first it changes its location to the mime type and header of a file for download. Then it does a timeout of one seccond and changes to the new location. After that the controller closes down and you are back to the same spot you where before but the page has refreshed. Thanks for the timeout thoughts.