Skip to content
This repository

Extension missing in Chrome 15 on Windows #9

Closed
bogtan opened this Issue November 21, 2011 · 15 comments

4 participants

Bogdan Tănase Stuart Knightley Rudie Dirkx pimvdb
Bogdan Tănase

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.

Stuart Knightley
Owner

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

Stuart Knightley Stuk closed this November 21, 2011
Bogdan Tănase

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.

Stuart Knightley
Owner

Which operating system and version of Chrome are you using?

Stuart Knightley Stuk reopened this November 21, 2011
Bogdan Tănase

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.

Stuart Knightley
Owner

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

Rudie Dirkx

Still no extension. Chrome 17 beta. Windows 7.

Bogdan Tănase

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.

Rudie Dirkx

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

Stuart Knightley
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

Rudie Dirkx

Works!

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

Stuart Knightley
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
pimvdb commented July 17, 2012

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.

Rudie Dirkx

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

Stuart Knightley
Owner
Stuk commented July 20, 2012

Very cool!

Stuart Knightley Stuk closed this October 05, 2013
Stuart Knightley
Owner

Working in Chrome 29

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.