开发者

Javascript window.open(xxx, "download") creates a blank page while download prompt

When I run window.open(file, "download") with safari, it opens a blank page while download prompt and the blank page stays开发者_运维知识库 there. I notice firefox opens a blank tab but it's close when download starts. Is there another javascript command/function that will work so there's no blank page opened in Safari?


Why don't you use window.location = file instead?

Redirecting to the file leads to the same behavior as clicking on a link to that file: you get the download prompt, and the browser stays on the current page!


Call window.open like this (it works in all major browsers):

window.open(file, '_parent', 'download');
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜