fwind
fwind

Reputation: 1314

Create GWT Anchor element with download attribute

I want to create a link element with the html download attribute from my GWT Presenter. Using an UI-Binder is not an option. I tried using an Anchor object but could not find an option there. Is it possible without using JavaScript?

Upvotes: 0

Views: 558

Answers (1)

j.s
j.s

Reputation: 236

Anchor a = new Anchor("download something", "download.html");
a.getElement().setAttribute("download", "");

This will create a link with an empty download attribute.

If you set a value for the attribute, this value will be used as the pre-filled filename in the Save prompt, for example:

a.getElement().setAttribute("download", "downloadname.html")

Upvotes: 3

Related Questions