开发者

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

开发者 https://www.devze.com 2023-03-14 04:02 出处:网络
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 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

精彩评论

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