Forum Discussion

Linda Werner's avatar
Linda Werner
Copper Contributor
Jul 10, 2018

Add-In: Embedding SharePoint content in iframe (xls, PDF)

We try to embed SharePoint content in an iFrame. Therefore we use the GUID of the doc to build the ifram URL.

([[HOST]‌]_layouts/15/WopiFrame.aspx?sourcedoc={[[GUID]]}&action=embedview&wdStartOn=1)

Tested with 3 different files.


  1. .pptx

Working fine.
Iframe-URL is

https://..._layouts/15/WopiFrame.aspx?sourcedoc={cfca68b9-c498-4c9b-a790-52d0f522b684}&action=embedview&wdStartOn=1

Everything is working fine. Preview is available.


  1. .xls

Iframe gets blocked.
Iframe-URL is

https://..._layouts/15/WopiFrame.aspx?sourcedoc={51bf3f39-addc-48aa-b9a0-7bd1b56d9f07}&action=embedview&wdStartOn=1

Browser shows the following message:

Refused to display 'https://..._layouts/15/WopiFrame.aspx?sourcedoc={51bf3f39-addc-48aa-b9a0-7bd1b56d9f07}&action=embedview&wdStartOn=1' in a frame because it set 'X-Frame-Options' to 'sameorigin'.

Its exactly the same URL as before, just the query parameters are different (different GUIDs).
When URLs get opened directly in the browser, you can see a small redirect. 
The PPTX gets redirected to https://xyz.sharepoint.com‌/:p/r/‌sites/.../_layouts/15/WopiFrame.aspx?....
The XLS gets redirected to https://xyz.sharepoint.com‌/:x/r/‌sites/.../_layouts/15/WopiFrame.aspx?....

 

QUESTION: Why does it get handled differently? How can we get the .xls to show up?


  1. .pdf

Iframe gets blocked.
Iframe-URL is

https://..._layouts/15/WopiFrame.aspx?sourcedoc={c967893a-26e4-45d9-876b-8d77d7575cc2}&action=embedview&wdStartOn=1
"Refused to display 'https://.../Shared Documents?RootFolder=%2Fsites%2Fsmarterpathtestingsite%2FShared Documents' in a frame because it set 'X-Frame-Options' to 'sameorigin'."

As it seems the URL doesnt work at all, it redirects to the Folder-View of that Sharepoint-Site. The same behavior when the URL gets opened up in the browser directly.

 

QUESTION: Is there any way to embed a PDF like this? In our local Dev environment it was working fine.

4 Replies

Resources