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

CFHEADER/CFCONTENT to offer a file to a user isn't triggering iFrame onload or onchange

LEGEND ,
Jun 28, 2017 Jun 28, 2017

Copy link to clipboard

Copied

Hello, all,

I'm submitting a form to itself (form target is set for an iframe on the same page) to generate an Excel file and offer it to the user for either download or open.  So far, everything is working great except one minor thing.

When the form submits, I add an animated circle 'progress' image to imply working in the background.  Once CFHEADER and CFCONTENT offer the file, I'm trying to get the gif to detach or hide.

I've tried using the iframe onLoad and onChange, but apparently that isn't being triggered.  Is there another way to trigger some kind of event when the file is offered?

<form target="exportToExcel" method="post" enctype="application/x-www-form-urlencoded">

...<select id="FQDN" name="FQDN">...</select>

</form>

<iframe id="exportToExcel" width="1" height="1" src="about:blank"></iframe>

Javascript:

FQDN = document.getElementById('FQDN');

... // set FQDN onchange to submit the form

ifrm = document.getElementById('exportToExcel');

ifrm.onload = function(){return function(){mc.innerHTML = ''}}; //I've also tried removeChild(), no worky.

V/r,

^ _  ^

Views

1.4K

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
Advocate ,
Jun 29, 2017 Jun 29, 2017

Copy link to clipboard

Copied

Im assuming the iFrame is on the same domain?

Does developer console say anything when trying this?

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 ,
Jun 29, 2017 Jun 29, 2017

Copy link to clipboard

Copied

Hi, haxtbh​,

I tried several times yesterday to log on and let everyone know that I found a workaround.  Stupid servers couldn't log me on.

Sadly, I will have to come back later to let everyone know how I did it.  We were just informed yesterday that we have until COB tomorrow to vacate the room that we are in so another department can have it.  So we are packing and moving.

V/r,

^ _ ^

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 ,
Jun 30, 2017 Jun 30, 2017

Copy link to clipboard

Copied

Sorry for taking so long to get back.  As the department lead developer, department FACCSM, and department EC (Equipment Custodian), I had a lot of equipment and other things that demanded my attention during this move. 

My workaround has only been tested in FireFox, but I'm about to test it in IE and Chrome.

What I was doing incorrectly was trying to use .onload and .onchange to detect when the file was done downloading.

My fix was to use:

ifrm.addEventListener('load',mc.removeChild(imge),false);

This appears to be working.

V/r,

^ _ ^

UPDATE: Sorry, I didn't answer your question.  Yes, same domain.  No error messages in dev con.

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 ,
Apr 02, 2019 Apr 02, 2019

Copy link to clipboard

Copied

This post is really old but I was curious if you had a complete code snippet for your solution.

Is 'imge' your overlay image?

​I'm trying to do something similar - using FW1 - user clicks on a button (which I disable), then create a spreadsheet with cfspreadsheet and serve that with cfcontent/header but can't go back and re-enable the submit button afterwards.

​Thanks!

​Jim

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 ,
Apr 02, 2019 Apr 02, 2019

Copy link to clipboard

Copied

Hi, Jim,

Unfortunately, I do not.  This was two years ago, and I honestly don't even remember which project this was for.

Oh, to have eidetic memory would be so cool in instances like this.

V/r,

^ _ ^

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 Expert ,
Apr 05, 2019 Apr 05, 2019

Copy link to clipboard

Copied

I might be missing something here, but you won't be able to add any script to the URI that's returning your file. Instead, you'll need additional script in the document that's opening the file in the iframe - you'll need an event handler to identify when the content has finished loading in the iframe. This might be a good start.

javascript - Capture iframe load complete event - Stack Overflow

Dave Watts, Eidolon LLC

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 ,
Apr 05, 2019 Apr 05, 2019

Copy link to clipboard

Copied

What I ended up doing

  • View - user clicks button (JS disables button during request)
  • Form submits to controller
  • Controller gets data, creates file and writes that to temp dir, sets rc.fileExists = yes
  • Controller redirects back to original view
  • In the view I check for rc.fileExists flag - if that exists I immediately do a window.open with a _blank with URL pointing to file
  • Browser does it's thing - opens the file in another tab but goes back to the original view and the button is reset since we refreshed the page

A bit clunky but it works and the client is happy.

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 ,
Apr 05, 2019 Apr 05, 2019

Copy link to clipboard

Copied

LATEST

https://forums.adobe.com/people/Jim+Priest  wrote

A bit clunky but it works and the client is happy.

And in the end, that's really the only important thing.

V/r,

^ _ ^

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