简体   繁体   中英

how to open microsoft office 365 word file in iframe in edit mode

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'.

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?

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM