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

Javascript will not execute if a cfdocument tag is in a document

Participant ,
Nov 12, 2015 Nov 12, 2015

Copy link to clipboard

Copied

I have a popup form action page that opens by using the form/target="_blank"  attribute.

The new document does a database insert and then creates a PDF using the <cfdocument> tag.

I'm trying update some elements on the parent/opener form page as it is common for the client to continue using the parent, make some changes, and generate another PDF. If I comment out the <cfdocument> tag my code works fine, the parent document is updated as I expected.

I'm not sure how to proceed, help much appreciated!

thanks, Lyndon

Javascript I'm trying to run just before the <cfdocument> tag:

<script>

        window.opener.document.getElementById('photoListTitle').innerHTML='test update';

</script>

Tag Attributes:

<cfdocument

        localUrl="yes"

        format="PDF"

        pageType="custom"

        pageWidth="2.2"

        pageHeight="3.375"

        marginBottom="0"

        marginTop="0"

        marginLeft="0"

        marginRight="0"

        orientation="portrait"

        backgroundVisible="yes"

        fontEmbed ="true"

        filename="PDFs/#Replace(BadgPhotoName,'.jpg','.pdf','All')#"

        overwrite="true">

          html...

</cfdocument>

Views

1.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

Enthusiast , Nov 13, 2015 Nov 13, 2015

What happens after the PDF is generated?  Is it automatically downloaded to the browser?  Have you tried using a hidden iFrame and some sort of modal notification to display that the file is being generated?  You could have the iframe page trigger a parent function to update HTML and return the link to the PDF file (so that it isn't automatically downloaded).  Files that are automatically downloaded performs a reset and any anything before the file download is ignored.

Votes

Translate

Translate
Enthusiast ,
Nov 13, 2015 Nov 13, 2015

Copy link to clipboard

Copied

What happens after the PDF is generated?  Is it automatically downloaded to the browser?  Have you tried using a hidden iFrame and some sort of modal notification to display that the file is being generated?  You could have the iframe page trigger a parent function to update HTML and return the link to the PDF file (so that it isn't automatically downloaded).  Files that are automatically downloaded performs a reset and any anything before the file download is ignored.

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
Participant ,
Nov 13, 2015 Nov 13, 2015

Copy link to clipboard

Copied

The PDF is the action page from my form. Adobe Reader (or the clients PDF reader) is the opener as the <cfdocument> tag make the server send the client a PDF file.

It seems once the template with a <cfdocument> tag opens, there is no DOM reference to the opener, since it's not an html file (that's my guess at this point anyhow).

I've decided I need to work on a solution that uses <cflocation> to get the client to the <cfdocument> tag instead of the <cfinclude> tag I'm using now. That way, hopefully, I can use the form/target CFML template to  insert my database record, update the parent page, and pass the new record ID as a url variable to a third template that contains my <cfdocument> tag. Then I can query the new record to get the information the <cfdocument> needs to do the print job.

I'll report back.

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
Participant ,
Nov 16, 2015 Nov 16, 2015

Copy link to clipboard

Copied

Well.... Disappointment.

<cflocation> has the same behavior???  If I comment out the cflocation tag the parent page updates, execute it and it does not.

I thought for sure it would work since I'm opening a new template.

Any ideas?

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
Participant ,
Nov 16, 2015 Nov 16, 2015

Copy link to clipboard

Copied

LATEST

Happiness!

Jamo, you the man! An <Iframe> tag did it.

Thank you so much.

Passing the BadgeID as a url variable did not work, but a session var worked fine.

<cfoutput>

    <script>

        window.opener.document.getElementById('photoTitle').innerHTML='#BadgeID#';

    </script>

</cfoutput>

<cfset Session.BadgeID=#BadgeID#>

<cfswitch expression="#Form.CardFormat#">

    <cfcase value="White">

        <iframe src="WhiteOccupationalLicense.cfm"></iframe>

    </cfcase>

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