Redirect user when document closes in office web apps

Issue:
We have a links to presentations on the page and when user clicks on the link the presentation is opening in Office Web Apps perfectly. But the issue is when user closes the document by clicking "X" icon on the top right, the user is being redirected to document library, whereas user wants to redirect to the page where he/she starts that is to the page where presentation links exist.

We cannot even send current page URL with source parameter like other list forms because the Web app viewer uses the URL available in WOPI Session Context cookie and if there is no cookie/URL exist then it will redirect to document library view by default.

Solution:
So before launching document in Web app viewer we have to update the cookie.
window.document.cookie = "WOPISessionContext=<Page URL>;path=/";

You can use the following script for this.

<script type="text/javascript">
function openUrl()
{
window.document.cookie="WOPISessionContext=<Page URL>;path=/";
window.location.href="<Document URL>?Web=1";
}
</script>
<a href="#" onclick="openUrl()">Open Presentation</a>

Comments

  1. Okay - but I'm not a programmer and have no idea to do what you just posted.

    ReplyDelete

Post a Comment

Popular posts from this blog

Switch from Classic to Claims Authentication in SharePoint 2010

How to query list data using web service