Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Extension missing in Chrome 15 on Windows #9

Closed
bogtan opened this Issue · 15 comments

4 participants

@bogtan

For example on http://jszip.stuartk.co.uk/ when click "Run" it prompts you to save the file "download" and it does not have ".zip" extension. If I save it and rename the file to "download.zip" everything is fine, but I think that the file should be by default saved with a ".zip" extension.

@Stuk
Owner

Please read all of the "Tell me more!" section on the page you linked.

@Stuk Stuk closed this
@bogtan

I'm sorry. Not specified that I'm using Chrome and in "Tell me more" section is Filename is "download.zip" but it's not.

@Stuk
Owner

Which operating system and version of Chrome are you using?

@Stuk Stuk reopened this
@bogtan

Chrome 15.0.874.120/Win 7
Tested in Chrome 15.0.874.106/Linux Ubuntu 10.04 and same issue.

Anyway... in Ubunut, the system recognize that is a zip file even if it does not have an extension.

@Stuk
Owner

Reproduced on Windows 7. I know it worked in the past so Chrome has regressed.

@rudiedirkx

Still no extension. Chrome 17 beta. Windows 7.

@bogtan

http://www.google.com/support/forum/p/Chrome/thread?tid=1c744e4ff30a95f7&hl=en
It seems to be a problem with Chrome browser. Meanwhile I tested in Safari and the problem is the same, with filename "Unknown".
I think that a solution would be to check if it's a webkit browser, if it is than add the extension from javascript code, else let the script do his job.

@rudiedirkx

You can't change the filename with Javascript. That's the problem. It has been for a year. Or did that change??

@Stuk
Owner

It appears the download attribute is being introduced[1] which would solve the problem . Could someone with easy access to Windows try this page[2] and see if the filename is set?

[1] http://www.whatwg.org/specs/web-apps/current-work/#attr-hyperlink-download
[2] http://html5-demos.appspot.com/static/a.download.html

@rudiedirkx

Works!

But... what if the script should trigger the download, and not a user click? Maybe you can fake the user click? a.click()?

@Stuk
Owner

I don't think it will be possible to force the start of the download. I will have to have a play around

@pimvdb

You can start the download automatically! The key is dispatchEvent. Here's a utility script of mine that can download a string as a file: http://jsfiddle.net/hSJSv/.

var downloadFile = function(options) {
  var blob = new Blob([options.data]);
  var evt = document.createEvent("HTMLEvents");
  evt.initEvent("click");
  $("<a>", {
    download: options.filename,
    href: webkitURL.createObjectURL(blob)
  }).get(0).dispatchEvent(evt);
};

This works fine in Chrome. Of course, the jQuery part could be extended to plain JavaScript and the prefix normalized.

Hope it helps.

@rudiedirkx

This is what I've been using for a while: https://gist.github.com/2623261

@Stuk
Owner

Very cool!

@Stuk
Owner

Working in Chrome 29

@Stuk Stuk closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.