Reputation: 107
In our webapp, we would like to be able to show different content at the same URL based on the host from which the site is opened. E.g https://localhost:44300 will behave differently depending on if it is opened from within a browser or an office js taskpane.
While that is the case, we would like not to include the office.js javascript until we know that the website is accessed from within an office js taskpane. Therefore it is also not possible to use Office.context.requirements.isSetSupported
.
The way we do it at the moment is by looking at the URL since it includes the _host_Info
. As an example we make the following check right now
if(window.location.search.indexOf('_host_Info=Word') > -1) { /* initiate app for word js addin */ }
Even though this works, it doesn't seem to be a good solution - especially if we want to navigate to other pages on the website. We therefore hope that there could be another way that the Office js host could be detected without having to include Office.js script beforehand
Upvotes: 3
Views: 512
Reputation: 8670
The scenario you describe is not supported -- and truthfully, I wonder how often it is that you want to use the exact same site both as an Office add-in and a standalone website. What we've most often seen is that people will re-use some of the same common libraries and CSS, but have different html pages for each scenario.
Note, too, that when run as an Office add-in, the page must include a reference to Office.initialize. This again makes it hard to re-use the same website contents for both an add-in and a standalone site. So my recommendation would be to refactor and share what you can, but have 2 separate html presences.
Hope this helps,
~ Michael Zlatkovsky, developer on Office Extensibility team, MSFT
Upvotes: 2