Well I may have stumbled on the answer, but you'll have to verify it.
The page I all javascript, and I set the url using:
window.location = downloadurl;
I went to Window documentation to see if there was a way to set location,
and saw there is a function Window.setLocation()
Oddly enough, the setLocation isn't in the api link here:
http://pyjs.org/api/pyjamas.Window-module.html
but it is shown in the source code the api links to here:
http://pyjs.org/api/pyjamas.Window-pysrc.html#open
Maybe that would work?
On Mon, Feb 20, 2012 at 10:27 PM, Stephen Waterbury <[email protected]
> wrote:
> To clarify, my question is solely about the front-end --
> i.e., I don't see a "natural" (API-based) way to make a menu item
> act like a link (aside from fetching content into an iframe).
> Menus, as far as I know, can only contain menu items, which
> can't be links. Or can they? I welcome any insight on that!
>
> I guess a somewhat kludgy way would be to cobble an html widget
> onto a menu and try to make it look like another menu item ...
> I might end up doing that. (As you can see, I'm kind of attached
> to having a menu bar ...)
>
> On 02/20/2012 10:14 PM, Charles Law wrote:
> > I don't have pyjamas experience doing this, but I have added similar
> > functionality to other sites with a web2py backend.
> >
> > For the other sites, I create a link to a function that returns the
> > file. In that function, on the server, set content disposition to
> > attachment. I believe this tells the browser to download the file
> > instead of navigating away from the page. The line of code I used in a
> > web2py backend was this:
> > headers['Content-Disposition'] = "attachment; filename=%s" %
> filename
> > I would guess if you can create a link, or open a url, to the file, or a
> > function that serves the file, you can have the download dialog popup.
> >
> > On Mon, Feb 20, 2012 at 9:20 PM, Stephen Waterbury
> > <[email protected] <mailto:[email protected]>> wrote:
> >
> > I'm probably being obtuse but can't see the easy way to do this:
> > in my app's menu bar, I'd like to have one of the menu items to
> > have an action that gets a binary file from a url. An iframe works
> > great if the content is html, but the thing I need it to get
> > is (ugh!) an ms word document (hateful, I know -- tell me about it!),
> > so I'd like to make the menu item behave as if it were just a
> > link so that it pops up a dialog so the user can save the doc
> > somewhere -- any easy way to do that?
> >
> > Thanks!
> > Steve
> >
> >
>