通过 JavaScript 提供下载

发布于 2024-07-09 13:39:18 字数 95 浏览 5 评论 0原文

我用 JavaScript 创建一个文件。 现在我希望能够将其提供给用户下载,这可能吗?

确切地说,它是我创建的 KML 文件,因此它是基本的 XML。

I create a file in JavaScript. Now I want to be able to make it available to the user as a download is this possible?

To be exact it is a KML File I create so its basic XML.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

傲鸠 2024-07-16 13:39:18

不。 与 JavaScript 不同。

决定浏览器自动提示您保存文件而不是尝试显示文件的是其 MIME 类型。 并且只有服务器可以设置 MIME 时间,因为它是响应标头的一部分。

当然,如果你在服务器上使用JS(使用Jaxer或其他引擎),那就是另一回事了......

no. Not sipmly with JavaScript.

What determines the browser to automatically prompt you for saving a file, instead of trying to display it, is its MIME type. And only the server can set the MIME time as it is part of the header of the response.

Of course, if you use JS on the server (with Jaxer or another engine), it's another story...

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文