I'm running into a problem using cfheader, and wondering if there's a workaround. What's happening is this:
I have a form page, and onSubmit of the form, a js validation function is called. This performs a number of tasks in addition to validation, and during its execution it looks at the document object. On the action page, a query is generated and fed to a custom changeQueryToCSV(query) function. Ultimately I want the user to be able to view (in Excel) and/or save the resulting .csv to their own pc. I use this at the bottom of my action page to make it happen: [code] <cfcontent type="application/csv"> <cfheader name="Content-Type" value="text/csv"> <cfheader name="Content-Disposition" value="attachment; filename=myFile.csv"> <cfoutput>#csvStringThatWasReturnedByFunction#</cfoutput> [/code] The problem is that the content type is being changed, and this seems to wipe out the DOM document object. When I submit the form, a dialog box comes up asking if I want to view or save myFile.csv, which I want. But then a js error pops up saying that "document.all" is not defined. As an attempt at working around, I used iframe. So the action page has only the iframe tags, with the src being another cfm page which contains all of the action code. This seems to work; document.all is defined in this case. But both the form page and the action page happen inside a modal window, which I want to close as soon as it's done executing. Any code on the action page (which has the iframe tags) to close the window causes it to close before the view/save dialog box appears. I also tried using window.open() on the action page instead of iframe, but I don't want any visible window to actually pop up. I've tried using cfmodule and cfinclude with no lock. Might cfthread work here? Mostly, I'm wondering if there's any other way to do what needs to be done (create csv file user can save to own pc) without using cfheader. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~| Order the Adobe Coldfusion Anthology now! http://www.amazon.com/Adobe-Coldfusion-Anthology/dp/1430272155/?tag=houseoffusion Archive: http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:351322 Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/groups/cf-talk/unsubscribe.cfm