These forums are now Read Only. If you have an Acrobat question, ask questions and get help from one of our experts.

Submitting Target?

nixopax
Registered: Feb 6 2009
Posts: 105

Is it possible to set a target window when submitting a form? In the standalone/desktop reader, submitting a form expects a response back into the reader, but when opening a URL, it'll open in a new tab of the default browser. In the browser reader seems to accept a response back into form if given, or will go to the page it submits if a text/html response is given. Opening a URL in the browser however will overwrite the PDFs browser with the new URL. Is there some way to treat it like a link in HTML using a target parameter like target="_blank"? Nothing in the API reference has indicated as such, but surely Adobe hasn't left something like this out?

thomp
Expert
Registered: Feb 15 2006
Posts: 4411
Unfortunately, I think that Acrobat simply hands off the HTML to the browser as if you were hitting a link on a page, except there's no parameters like "target" that can be included to tell the browser where to open the page.

But there is something you can do. Return FDF data that contains a single line of JavaScript. The "app.launchURL" function has a parameter for opening an URL in a new Page. I haven't tested this out in all situations, but it should work.

I think there are some other ideas/opinions on this exact point on this forum and the Adobe User to User forum.

Thom Parker
The source for PDF Scripting Info
[url=http://www.pdfScripting.com]pdfscripting.com[/url]

The Acrobat JavaScript Reference, Use it Early and Often
[url=http://www.adobe.com/devnet/acrobat/javascript.php]http://www.adobe.com/devnet/acrobat/javascript.php[/url]

Thom Parker
The source for PDF Scripting Info
www.pdfscripting.com
Very Important - How to Debug Your Script

nixopax
Registered: Feb 6 2009
Posts: 105
I've done JavaScript in the FDF response before, but it brings up a warning and fails if your security settings are too paranoid. I think that when you're warned that something bad could happen, it scares off the majority of less tech savvy users. I've seen people confused when they're told "You're entering a secured server(https) and that it makes it safer for you", and suddenly they don't know what to do. But perhaps, maybe just return a URL and have a JavaScript function check for said URL and then launch the variable returned? I made a form recently that submitted to a database and then needed to redirect you to a payment page, and in the standalone reader, it had the response return into the PDF nicely, as well as open a browser window in the background with the payment page, but with the browser version, it submitted and redirected away from the PDF at the same time, so the info went into the database but without verification to the user that it was successful . I'll have to fiddle around with a script to read the FDF response before doing the getURL.

this.submitForm();this.getURL();

should be

this.submitForm();startListener("cReturnMessage");

Then the startListener function would start a timer and every timeout it would check the cReturnMessage field for a value and once the condition is met, do a confirm() to initiate redirecting to the payment page, or maybe have other options set.

As I was typing, I scoured over the API again, and gave LaunchURL a try. It has a bNewFrame option that I gave a try. It worked like a charm. I'm going to do this from now on. Too bad it's 7+

app.launchURL("http://www.example.com/", true); //if bNewFrame is set to true, then a new window will open.
thomp
Expert
Registered: Feb 15 2006
Posts: 4411
Hey, that's a great strategy. Less direct, but it avoids many of the security problems. However, since the PDF has already submitted the form to one URL, the launchURL should cause a security popup since the PDF has contacted two different web sites. The only way to avoid this is to use the crossdomain file introduce in Acrobat 9. So even less compatibility:(

Thom Parker
The source for PDF Scripting Info
[url=http://www.pdfScripting.com]pdfscripting.com[/url]

The Acrobat JavaScript Reference, Use it Early and Often
[url=http://www.adobe.com/devnet/acrobat/javascript.php]http://www.adobe.com/devnet/acrobat/javascript.php[/url]

Thom Parker
The source for PDF Scripting Info
www.pdfscripting.com
Very Important - How to Debug Your Script

nixopax
Registered: Feb 6 2009
Posts: 105
Actually, I ran into that exact problem with the form I made. I fixed the issue with an HTML page that had a form with hidden form fields and a JavaScript in the body tag:

<body onLoad="javascript:document.formname.submit();">
Both pages were hosted on the same server, but different subdomains. It generated the warning, so I had both pages in the same subdomain, and voilĂ !