10 January, 2012

Opening HTML Files in Sharepoint 2010

In SharePoint 2010 I have created a Library in which I have placed an Html document and related file system to go with the document.  Under Library Settings / Advance Settings I have selected (Open in Browser). However, when I click on the file to open it in SharePoint it does not open in the browser but opens up a dialogue box to save the file locally.


Requirements: We wanted the ability to open the HTML document directly within the browser. 


Multiple Requirements:
1. upload html files to a sharepoint library: in document library we can add html files, but the problem is when i open that html file in the library a popup message box appears asking to save the file. is there a way to open these html files in a browser like documents are open in word.

2. Asking to save file when try to open it from sharepoint: When I try to open the files(.html,.xml.....) which are uploaded to sharepoint,Its not getting opened directly instead a pop up window to save the file is coming.

3. In a document library when I check out a Word document, I get prompted "You are about to check out ___" with the option to use Local Drafts folder.  I can then open the document from Local Drafts and upon saving, I get prompted to check in.

4. If you have converted Word document to HTML file and uploaded it to SharePoint.  Now I would like to make modification to the new HTML file and save it through SharePoint.  However, it is not possible because it the HTML file doesn't "save" option, only "save as" option. 

Resolution:
By default, Sharepoint 2010 is blocking the ability to open HTML documents directly from a document library. 

However this can be changed by adjusting the browser file handling option. The option is located here:

1. Central Admin\Application Management\Manage Web Applications.
2. Select General Settings for the specified web application
3. For Browser file handling, select permissive. The default is strict​

Detailed Explanation as why it happens:

This is intentional behavior. In SP2010 Microsoft has tightened up security for people with contribute access. Previously, a malicious user could upload a file with script in it that would get run as whoever browses to the page ie. an admin. In 2010 where we have a javascript object model, this would be a big problem if we didn't have this restriction in place.
Browser File Handling  
Specifies whether additional security headers are added to documents served to web browsers. These headers specify that a browser should show a download prompt for certain types of files (for example, .html) and to use the server's specified MIME type for other types of files.
Permissive Specifies no headers are added, which provides a more compatible user experience. 
Strict Adds headers that force the browser to download certain types of files. The forced download improves security for the server by disallowing the automatic execution of Web content that contributors upload

If you have any queries/questions regarding the above mentioned information then please let me know. I would be more than happy to help you as well as resolves your issues, thank you

14 comments:

  1. Hi, nice article with detailed information. I am facing same issue for pdf files. I have created HR Policy document library in my site where PDF files are uploaded. On click of document it ask to save & then open it. I have tried the above solution to open pdf frm browser instead of first to save but it gives an error as "An unexpected error has occurred.

    Troubleshoot issues with Microsoft SharePoint Foundation.

    Correlation ID: 10ac7c26-201a-474d-91b2-c1fc7776afdb ". Also checked in eventviewer but not found anything. I don't know how to fix this issue.
    Please share the solution for the same.

    Thanks,
    Poonam

    ReplyDelete
    Replies
    1. above mentioned solution will perfectly work for the office docs

      Microsoft SharePoint supports opening, editing as well as deletion of documents i.e. office documents. PDF docs belongs to third party product i.e. ADOBE.

      We can store PDF docs on sharepoint site but if you wanna modify the document then you need to save it to your desktop. that is default behavior with respect to PDF docs.

      Delete
    2. Hi,

      I have uploaded the HTML documents, but users are saying when they click this link, it should open in a new window ...please let me know how to achieve this ?
      I read something about updating onet.xml files
      what exactly has to be updated there ??

      Delete
    3. updating onet.xml will be for the complete farm and it will be applicable for all the document types. before applying this global fix, i would recommend you to use this workaround: Right click on HTML documents and Open in new tab. this will suffix user requirements. if this wont be accepted then please let me know so that we can discuss on the onet fix. Thank you

      Delete
    4. Hi Amol,
      this was not agreed by the user..please let me know how to fix in the onet.xml file

      please give me the exact location of onet.xml and steps and where to edit the file...( I am new to coding!, hope you understand)

      Delete
    5. IMP NOTE: make sure you take the backup of onet.xml file before making any changes and store it somewhere safely.

      Please refer the following path where you will get the onet.xml
      C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\14\TEMPLATE\GLOBAL

      Refer this for next process!

      Let me know in case of any queries, Thank u

      Delete
  2. Thanks, Refer this for next process ?? what next needs to be done after opening onet.xml ?

    ReplyDelete
    Replies
    1. Please refer this link for complete details:
      http://marcellotonarelli.wordpress.com/2010/12/09/sharepoint-open-documents-in-new-window/

      Delete
  3. so operation 5 & 6 cannot be performed

    did steps 2 & 3 but unable to get the functionality ( html files opening in new window)

    ReplyDelete
  4. in SP2013 line 5 cannot be found

    ReplyDelete
    Replies
    1. i am still checking on this, trying to figure out as why its not working! Thanks for your patience

      Delete
    2. Okay, here is the solution-

      http://technologykitchen.wordpress.com/2013/05/29/open-document-library-documents-in-new-window/

      what you have to do-

      -Open the document library in which HTML files are present

      -On that same page, you need to add a new webpart i.e. content editor webpart

      -use the script mentioned in the above article and placed it inside the webpart

      -click ok

      -now check the results. do let me know, thank u.

      Delete
  5. No sorry, my server does not have internet so this java code which is refering to a google library will not work

    ReplyDelete
    Replies
    1. No i think there is some disconnect here. There is nothing to do with the server here!

      This can be done by client machine also. The page where the document library exist, you just have to edit that page- add a new content editor webpart- paste the code.

      thats it! pls check and let me know the results. Thank you

      Delete

Your feedback is always appreciated. I will try to reply to your queries as soon as possible- Amol Ghuge

Note: Only a member of this blog may post a comment.