• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

If using CFCONTENT and CFHEADER to stream an Excel file, will Javascript still work?

LEGEND ,
Dec 18, 2015 Dec 18, 2015

Copy link to clipboard

Copied

Hello, all,

I'm using a hidden iFrame that loads a page using CFCONTENT and CFHEADER to stream an Excel file from a form submit.  I'm _trying_ to use JavaScript to change the value of the button element that submits the form in the parent page.

I'm not seeing any success.  Does Javascript still run when a page uses CFCONTENT and CFHEADER?

I can't even get a simple JS alert() to work.

V/r,

^_^

Views

2.0K

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Community Expert , Dec 19, 2015 Dec 19, 2015

I wouldn't expect Javascript to run when you use,

<cfheader name="Content-Disposition">

<!--- XLS --->

<cfcontent type="application/vnd.ms-excel">

<!--- XLSX --->

<!--- <cfcontent type="application/vnd.openxmlformats-officedocument.spreadsheetml.sheet">--->

These tags result in Coldfusion sending binary content, that is, Excel code, to the browser.

Votes

Translate

Translate
Community Expert ,
Dec 19, 2015 Dec 19, 2015

Copy link to clipboard

Copied

I wouldn't expect Javascript to run when you use,

<cfheader name="Content-Disposition">

<!--- XLS --->

<cfcontent type="application/vnd.ms-excel">

<!--- XLSX --->

<!--- <cfcontent type="application/vnd.openxmlformats-officedocument.spreadsheetml.sheet">--->

These tags result in Coldfusion sending binary content, that is, Excel code, to the browser.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Dec 21, 2015 Dec 21, 2015

Copy link to clipboard

Copied

Hi, BKBK‌,

I kind of thought it wouldn't work.  So, once the header information is sent and a binary follows, nothing else is executed.

Do you know of a way to use JavaScript to detect when a binary is done streaming?  I'm just trying to figure out a way to change the text of a button in the browser after a file is downloaded.

It will start out "Generate Report", then change to "Loading..." when the user clicks on it.  I'd like to switch it back to "Generate Report" after the binary either starts or is done streaming.

Thank you, and V/r,

^_^

UPDATE:  Ben Nadel figured it out.  Here's the link for anyone else who might want to do the same.

Tracking File-Download Events Using JavaScript And ColdFusion

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Dec 28, 2015 Dec 28, 2015

Copy link to clipboard

Copied

LATEST

You can't - once the browser has detected the content type - in many cases the mode of browser operation will not even load the browsers JavaScript interpreter. You should understand that the web is a very dirty place. Servers are misconfigured, files are saved and named incorrectly, and web browsers are forced to deal with it all. We’ve seen that browsers cannot trust the Content-Type header and instead must try and determine the file type of content using content detection (Magic Numbers in byte data that uniquely identifies specific file types ). So far, we have only covered content detection for binary files like images, fonts and/or popular file types lide MS Office files. This is fairly easy, since browsers can just look for magic numbers to determine the format. Imagine trying to determine if a string of text is HTML or JavaScript. Content detection for text is very tough indeed and its unlikely something like what you are looking for will ever exist -- nor should it... Perhaps you should consider loading a document object model first and then task the background task of download via a javascript operation much like you see on source forge

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources
Documentation