0

I have written a sharepoint add-in that is more userfriendly to manage documents in a library. To make it easy for me im using Allitems.aspx together with an id to preview document.

https://doamin.sharepoint.com/teams/vlsdev/VLSdokument/Forms/AllItems.aspx?id=%2Fteams%2Fvlsdev%2FVLSdokument%2FdemoDoc.docx&parent=undefined

preview

The preview pops upp in a new tab. Problem is if the user uses the "close" button marked red, in the corner they arrive at the document library where i dont want normal users to be.

https://domain.sharepoint.com/teams/vlsdev/VLSdokument/Forms/AllItems.aspx?id=undefined

document library

Can i some how remove that close button? Redirect?

Or do i have to write my own custom preview in an iFrame?

0

I understand from your scenario your goal is to preview the document from a SharePoint add-in you are building a URL which you can be used to open from a browser tab.

To achieve this scenario we have used 2 options. You can try and see is this what you are looking for

Preview Document From Browser tab

Syntax:

_spPageContextInfo.webAbsoluteUrl + /_layouts/15/WopiFrame.aspx?sourcedoc=file guid&file=file name&action=default

Example

https://demo.sharepoint.com/_layouts/15/WopiFrame.aspx?sourcedoc={CA9C01CE-CB61-4F0E-903D-16BEB63C4C6E}&file=demo.docx&action=default

Embed document in a page

<iframe src='https://demo.sharepoint.com/_layouts/15/WopiFrame.aspx?sourcedoc={CA9C01CE-CB61-4F0E-903D-16BEB63C4C6E}&file=demo.docx&action=default&action=embedview&wdStartOn=1' width='476px' height='288px' frameborder='0'>This is an embedded <a target='_blank' href='https://office.com'>Microsoft Office</a> document, powered by <a target='_blank' href='https://office.com/webapps'>Office Online</a>.</iframe>

Either way works for us.

  • Yeah i have used WopiFram aswell but with the use of Allitems i get more built in sharepoint functionality in the preview, like open document in online/word, share, download, delete and so on. But maybe the way to go is custom with wopiframe. – QuiXXotic May 29 '17 at 12:09

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.