简体   繁体   English

JavaScript / SharePoint - 强制文件下载

[英]JavaScript / SharePoint - Force file download

SITUATION :情况

I have a file that has to be opened by an unknown number of users on my SharePoint site.我的 SharePoint 站点上有一个文件必须由未知数量的用户打开。 It's an InfoPath form, which is automatically opened by the browser per the MIME Types settings.它是一个 InfoPath 表单,由浏览器根据 MIME 类型设置自动打开。 My organization uses IE, and since I'm a 'node' of the organization, I can't access headers or .htaccess files.我的组织使用 IE,由于我是组织的“节点”,所以我无法访问标头或 .htaccess 文件。 It's also an intr.net with TONS of security settings, many of which have been changed so often on individual computers it's impossible to account for them.它也是一个具有大量安全设置的 intr.net,其中许多设置在个人计算机上经常更改,以至于无法解释它们。

ATTEMPTS :尝试

I've tried JavaScript target='_blank' , and execCommand .我试过 JavaScript target='_blank'execCommand Unfortunately neither of them work and I'm at my wits end!不幸的是,它们都不起作用,我束手无策! The Infopath form is not browser-enabled, and the document library is set to open in Client Program, yet most people cannot open the form. Infopath 表单支持浏览器,文档库设置为在客户端程序中打开,但大多数人无法打开该表单。

QUESTION :问题

Is there a way using JavaScript or a similar Client-side language to prompt that 'Open' box?有没有办法使用 JavaScript 或类似的客户端语言来提示“打开”框? Unless someone knows of a way to configure it to always prompt instead of automatically open in the browser, that is.除非有人知道将其配置为始终提示而不是自动在浏览器中打开的方法,否则。

The soultion is to really work with it on the server.解决方案是在服务器上真正使用它。 The Content-disposition header needs to be set.需要设置Content-disposition header。 MS KB Aticle微软知识库文章

Teh sharepoint admin should be able to set the setting in the General Settings and set Browser File Handling to strict. Teh sharepoint 管理员应该能够在常规设置中设置设置并将Browser File Handling设置为严格。

I haven't used InfoPath before, but it seems like this problem might be related to browser file handling settings.我以前没有使用过 InfoPath,但看起来这个问题可能与浏览器文件处理设置有关。

By default, browser file handling is set to strict at the web-app level (as it should be).默认情况下,浏览器文件处理在 Web 应用程序级别设置为严格(应该如此)。 However, this can be overridden at the document library level and as far as I know, it's a hidden setting (at least I've never seen it in the UI), so you'll need to use SharePoint Manager or PowerShell to view/change it.但是,这可以在文档库级别覆盖,据我所知,这是一个隐藏设置(至少我从未在 UI 中看到过),因此您需要使用 SharePoint Manager 或 PowerShell 来查看/更改。

If you need to, you can use PS to add exceptions to this setting at the web-app level.如果需要,您可以使用 PS 在 Web 应用程序级别为此设置添加例外。 Not sure if you can do the same at the doclib level.不确定您是否可以在 doclib 级别执行相同的操作。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM