1

based on Embed a Word document in your blog, I know how can I embed a word document in an iframe in read-only mode. but I'm looking for a solution to open it in edit mode.

is there any way to open an office 365-word document in edit mode on an external website?

I tried to just put a sample document in an iframe but had no sucess.

update:

also I found this thread https://answers.microsoft.com/en-us/msoffice/forum/all/embed-o365-edit-link-in-an-iframe/ce46bc84-755a-4cf3-98ca-776ba143b671?page=2 but looks like it's too old and maybe since 2016 some method and solution has been developed to embed edit mode.

<iframe src="https://onedrive.live.com/edit.aspx?resid=5D099B6B963F20FB!118&ithint=file%2cdocx&wdOrigin=OFFICECOM-WEB.START.MRU">
</iframe>

console error:

Refused to display 'https://onedrive.live.com/' in a frame because it set 'X-Frame-Options' to 'sameorigin'.

ADyson
  • 57,178
  • 14
  • 51
  • 63
Yuseferi
  • 7,931
  • 11
  • 67
  • 103

2 Answers2

0

The reason for this is, that the browser is sending an "X-Frame-Options: SAMEORIGIN" response header. This option prevents the browser from displaying iFrames that are not hosted on the same domain as the parent page.

See: Mozilla Developer Network - The X-Frame-Options response header

A solution will be to load it as an embed so Mircosoft will not redirect you a 1000 times. Mabye look at this: How do I render a Word document (.doc, .docx) in the browser using JavaScript?

Dennis
  • 54
  • 8
0

If you do not want stay stucked in this trouble, have one way to resolve this, but this is very complexy/dificultly, following these steps:

  1. You need an Office 365 account and provide a SharePoint site were you'll add all files that you want to open in edit mode (put all files into a Document Library list);
  2. Following this tutorial to bypassing this SharePoint site (that you added documents to be opened in edit mode) into HTML Iframe: How To Bypass Cross Domain Issues To Display SharePoint Online Pages Within Iframe From An External Domain
  3. Into SharePoint site, develop a Web Part that allow users to open files in edit mode, following this tutorial: Office Web Apps (Word, Excel, PowerPoint) Link To "Open File In Iframe";

I believe in this way like the best alternative to resolves this challenge.

Antonio Leonardo
  • 1,805
  • 1
  • 8
  • 18
  • Hi Antonio, thank you for your attention. looks like the suggested solution needs ASP langague. our server is PHP base and there is no chance to write code in ASP. – Yuseferi Mar 13 '22 at 15:24
  • 1
    Hi @Yuseferi, you do not need to host an asp/asp.net site; the idea is, you make a Office365 assignment (everything in Office365 is based in cloud) and into your site hosts you'll consume this services by your site iframe. About SharePoint Online, learn more at these articles: [Introduction to SharePoint in Microsoft 365](https://learn.microsoft.com/en-us/sharepoint/introduction) and [What is SharePoint Online?](https://www.office365brasil.com.br/sharepoint-online.htm) – Antonio Leonardo Mar 13 '22 at 15:48
  • Could you provide a sample if it's just an iframe? – Yuseferi Mar 13 '22 at 19:42