Search code examples
htmloffice-2013file-urijavascript-api-for-office

Using File:/// Protocol Links with Javascript API for Office


Background

I'm writing an excel app using the Javascript API for Office. (Office 2013). Inside that app, I have several links to folders on my computer/server, which I want to access from the app using the file protocol.

I've tested the file protocol with a dummy HTML file, using this link:

<a href="file:///C:\Users\User\Desktop">C:\Users\User\Desktop</a>

It works perfectly, opening up the Desktop folder. I've also tested using a networked drive, and it works as well.

Problem

When I add this dummy link into an HTML page in my Excel web app, clicking on it does nothing. When I right click -> Open, IE11 opens a new instance (which doesn't happen with mailto: links), and asks if I'd like to give permission. After I do give permission, the folder is opened.

Goal

I want a single left click to open the folder location without the permissions box ever popping up. Worst case, I want to be able to have the user open a dummy link once during app setup and then once permission is given avoid having to right click -> open.

Question

How can I accomplish the goal here? Is Office just locking down the links?


Update

The primary issue I've found out is that the site I'm hosting the app on wasn't a trusted site. Links using the file protocol only work on intranet and trusted sites. So the only question now is whether the Office store location is trusted.


Solution

  • The problem here lies in the way that Office Apps work. A manifest file is stored with the Office Store, and that is what users download. That manifest points to a server location that the app developer specifies, and that is the location from which the app is served. That is the location which must be added to Trusted Sites in IE.

    enter image description here

    Therefore to get the File Protocol working smoothly, I'd need to include instructions with my App on adding my hosting server to the Trusted Sites domain, and I'd have to avoid ever changing domains.