Problem to call Javascript to download XLS file (IE8)

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

Problem to call Javascript to download XLS file (IE8)

inanda.menezes
This post was updated on .
Steps to reproduce:
Orbeon version: Orbeon Forms 3.9.1 PE or Orbeon Forms 3.9 PE
Browser: Internet Explorer 8 (It works well for other browsers.)

Create a link button in form builder and add the following action:
 <xforms:action ev:event="DOMActivate">
                                        <xxforms:script>       
                                                                              window.open('http://www.eff.org/files/EFF_Social_Network_Law_Enforcement_Guides.xls');
        </xxforms:script>
                                    </xforms:action>


Expected: Open a new window and then show the dialog for the user, so that the user can download the XLS file.
Result: When using IE8, it opens the new window and closes it again and does not show any dialog to the user.

NOTE:This same javascript function works perfectly in IE8 with a normal HTML page.

Why does it happen in IE8 when calling this javascript from orbeon form?






Reply | Threaded
Open this post in threaded view
|

Re: Problem to call Javascript to download XLS file (IE8)

Erik Bruchez
Administrator
Inanda,

I can only guess that this is due to the browser's popup blocker.
Depending on which JavaScript code tries to open a window/document,
the browser might block it. I think there are two scenarios:

1. window open is the result of JavaScript code triggered by a user
action: works
2. window open is the result of something else (including an Ajax
response): fails

Unfortunately #2 is the case you are hitting with xxforms:script.

It's a bit sad because the browser could probably include Ajax
request/response so that this falls into case #1. Oh well.

So this is why on the Form Runner summary page, we use a trick to open
the PDF. See:

https://github.com/orbeon/orbeon-forms/blob/master/src/resources/apps/fr/summary/view.xhtml#L789

Basically we add a JavaScript listener to bypass the Ajax request and
open a link stored in an <a> element using an AVT for the href.

-Erik

On Wed, Mar 7, 2012 at 1:37 AM, inanda.menezes <[hidden email]> wrote:

> Steps to reproduce:
> Orbeon version: Orbeon Forms 3.9.1 PE or Orbeon Forms 3.9 PE
> Browser: Internet Explorer 8 (It works well for other browsers.)
>
> Create a link button in form builder and add the following action:
>  <xforms:action ev:event="DOMActivate">
>                                        <xxforms:script>
>
> window.open('http://www.eff.org/files/EFF_Social_Network_Law_Enforcement_Guides.xls');
>        </xxforms:script>
>                                    </xforms:action>
>
>
> Expected: Open a new window and then show the dialog for the user, so that
> the user can download the XLS file.
> Result: When using IE8, it opens then new window and closes it again and
> does not show any dialog for the user.
>
> NOTE:This same javascript function works perfectly in IE8 with a normal HTML
> page.
>
> Why does it happen in IE8 when calling this javascript from orbeon form?
>
>
>
>
>
>
>
>
> --
> View this message in context: http://orbeon-forms-ops-users.24843.n4.nabble.com/Problem-to-call-Javascript-to-download-XLS-file-IE8-tp4452742p4452742.html
> Sent from the Orbeon Forms (ops-users) mailing list archive at Nabble.com.
>
>
> --
> You receive this message as a subscriber of the [hidden email] mailing list.
> To unsubscribe: mailto:[hidden email]
> For general help: mailto:[hidden email]?subject=help
> OW2 mailing lists service home page: http://www.ow2.org/wws
>


--
You receive this message as a subscriber of the [hidden email] mailing list.
To unsubscribe: mailto:[hidden email]
For general help: mailto:[hidden email]?subject=help
OW2 mailing lists service home page: http://www.ow2.org/wws
Reply | Threaded
Open this post in threaded view
|

Re: Problem to call Javascript to download XLS file (IE8)

inanda.menezes
This trick would work if I were not using Liferay.
It does not work for me, because I'm using the orbeon proxy portlet with liferay and If I try to use a link like this, it's gonna complain about the orbeon.path: "Unsupported path".

The work around to solve it was to create a download page and from the orbeon link we call this download page in a new window. This page has a javascript to get the url by parameter and redirect the user to the file URL.

Unfortunately it's the only way I could get it working in IE8.
Reply | Threaded
Open this post in threaded view
|

Re: Re: Problem to call Javascript to download XLS file (IE8)

Erik Bruchez
Administrator
Great, thanks for sharing. -Erik

On Fri, May 4, 2012 at 4:55 AM, inanda.menezes <[hidden email]> wrote:

> This trick would work if I were not using Liferay.
> It does not work for me, because I'm using the orbeon proxy portlet with
> liferay and If I try to use a link like this, it's gonna complain about the
> orbeon.path: "Unsupported path".
>
> The work around to solve it was to create a download page and from the
> orbeon link we call this download page in a new window. This page has a
> javascript to get the url by parameter and redirect the user to the file
> URL.
>
> Unfortunately it's the only way I could get it working in IE8.
>
> --
> View this message in context: http://orbeon-forms-ops-users.24843.n4.nabble.com/Problem-to-call-Javascript-to-download-XLS-file-IE8-tp4452742p4608442.html
> Sent from the Orbeon Forms (ops-users) mailing list archive at Nabble.com.
>
>
> --
> You receive this message as a subscriber of the [hidden email] mailing list.
> To unsubscribe: mailto:[hidden email]
> For general help: mailto:[hidden email]?subject=help
> OW2 mailing lists service home page: http://www.ow2.org/wws
>


--
You receive this message as a subscriber of the [hidden email] mailing list.
To unsubscribe: mailto:[hidden email]
For general help: mailto:[hidden email]?subject=help
OW2 mailing lists service home page: http://www.ow2.org/wws