Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
Question
Thursday, November 25, 2010 10:56 AM
hi
i am new to SharePoint 2010. i have a fair knowledge on working with document library. i want to browse and add html files to libraries(not like in wiki 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.
All replies (7)
Thursday, November 25, 2010 12:02 PM âś…Answered | 1 vote
From Central Admin go to your web application general settings and you'll find Browser file handling setting to be set to Permissive (default is Strict).
**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
|
Marco Rizzi @Avanade Italy http://blog.marcorizzi.com
Thursday, November 25, 2010 11:49 AM
SharePoint considers HTML files that stored in Libraries just as files. It won't take content that specified in HTML and process/render.
If you SharePoint Server File System access then open SharePoint Root Folder(C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\14\Layouts\ and create a new folder. Then copy all your HTML files in that. From SharePoint site you can access those files like /_Layouts/FolderName/HtmlFileName.htm
Or Just follow the solution suggested by Marco Rizzi below.. :-)
Regards,
Venkatesh R
/* My Code Runs in Visual Studio 2010 */
http://geekswithblogs.net/venkatx5/
Thursday, November 25, 2010 10:44 PM
Hi Amit,
the layouts folder is not made to store content Marko Rizzi is right about the settings for HTML Files.
Kind regards Stefan
http://www.n8d.at/blog
twitter: n8design
MCTS - SharePoint / WSS Configuration and Development
Friday, November 26, 2010 10:37 AM
Thanks Marco!!!! your solution works.
one more question, when i click that html file it is open within the same browser. is it possible to open these files in popup window?
Friday, November 26, 2010 10:49 AM
Hi,
nope there is no out of the box option to open the file in a new window. What you could do is attach jquery to open all html files in a new window.
Kind regards Stefan.
http://www.n8d.at/blog
twitter: n8design
MCTS - SharePoint / WSS Configuration and Development
Wednesday, November 23, 2011 4:49 PM
I hope it's ok to ask this here since it seems relevant...I too am trying to upload html files to a Sharepoint account. The html files are at www.experient.info, though I have them locally as well. Once I upload them to Sharepoint, how do I convert them to the aspx files that Sharepoint displays? Is there a simple way, or does one need to know asp to do so? Thank you for any suggestions.
Wednesday, May 9, 2012 6:11 PM
There are two ways to do this involving overriding the internal XSL that is used to render the main hyperlink for document libraries.
First, I'll show you the method that voids your warranty and is global to all sites on your server. Then, Ill explain how to do the edit properly targeted to one specific document library (requires you develop a custom .wsp solution in visual studio). So, here goes:
We essentially need to override the default rendering template for the table cell that normally contains the hyperlink and context menu chevron. To 'void your warranty' open the original xsl template, use NotePad to open up \14\TEMPLATE\LAYOUTS\XSL\fldtypes.xsl and see the template that spans lines 1793 through 1874. Then, find the final 'otherwise' block which looks like this:
<xsl:otherwise> <!-- warning: this code has optimization in webpart. Change it must change the webpart code too!--> <a onfocus="OnLink(this)" href="{$thisNode/@FileRef}" onmousedown="return VerifyHref(this,event,'{$XmlDefinition/List/@DefaultItemOpen}','{$thisNode/@HTML_x0020_File_x0020_Type.File_x0020_Type.mapcon}','{$thisNode/@serverurl.progid}')" onclick="return DispEx(this,event,'TRUE','FALSE','{$thisNode/@File_x0020_Type.url}','{$thisNode/@File_x0020_Type.progid}','{$XmlDefinition/List/@DefaultItemOpen}','{$thisNode/@HTML_x0020_File_x0020_Type.File_x0020_Type.mapcon}','{$thisNode/@HTML_x0020_File_x0020_Type}','{$thisNode/@serverurl.progid}','{$thisNode/@CheckoutUser.id}','{$Userid}','{$XmlDefinition/List/@ForceCheckout}','{$thisNode/@IsCheckedoutToLocal}','{$thisNode/@PermMask}')"> <xsl:value-of select="$thisNode/@FileLeafRef.Name" /> </a> <xsl:if test="$thisNode/@Created_x0020_Date.ifnew='1'"> <xsl:call-template name="NewGif"> <xsl:with-param name="thisNode" select="$thisNode"/> </xsl:call-template> </xsl:if> </xsl:otherwise>
Then strip all the onclick, onmouseover, onmousedown stuff off of the <a> tag and supply a 'target="new"' attribute. Then hit save. Your final version of the above snippet should now look like this:
<xsl:otherwise> <a href="{$thisNode/@FileRef}" target="_new"> <xsl:value-of select="$thisNode/@FileLeafRef.Name" /> </a> <xsl:if test="$thisNode/@Created_x0020_Date.ifnew='1'"> <xsl:call-template name="NewGif"> <xsl:with-param name="thisNode" select="$thisNode"/> </xsl:call-template> </xsl:if> </xsl:otherwise>
There is a way to do this and works particularly well if you are developing a custom .wsp solution file in Visual Studio that you intend to deploy to whatever sharepoint installation you are working with.
In Visual Studio you'll need to right-click and add a SharePoint Mapped Folder... then, select the XSL directory.
Once the XSL mapped directory is added to your project, right click and add an .xsl file into it, for example, we'll call this doclibrary_custom_view.xsl.
Before I get into the contents of the above xsl file, let's go ahead and put a reference to the file in your custom library definition. Find the Schema.xml file related to your custom list definition and in the 'Views/View' elements you will need to fill in the following XslLink element, like so:
<Views> <View BaseViewID="0" Type="HTML" MobileView="TRUE" TabularView="FALSE" FreeForm="TRUE"> <Toolbar Type="Standard" /> <XslLink Default="TRUE">doclibrary_custom_view.xsl<XslLink> <RowLimit Paged="TRUE">30</RowLimit> <ViewFields>
I'll show the specifics of the xsl file in a successive post. I have to run for the moment... ok, I'm back (did you miss me?) Here's what the above .xsl file should have inside of it:
<?xml version="1.0" encoding="utf-8"?><xsl:stylesheet xmlns:x="http://www.w3.org/2001/XMLSchema" xmlns:d="http://schemas.microsoft.com/sharepoint/dsp" version="1.0" exclude-result-prefixes="xsl msxsl ddwrt" xmlns:ddwrt="http://schemas.microsoft.com/WebParts/v2/DataView/runtime" xmlns:asp="http://schemas.microsoft.com/ASPNET/20" xmlns:__designer="http://schemas.microsoft.com/WebParts/v2/DataView/designer" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:msxsl="urn:schemas-microsoft-com:xslt" xmlns:SharePoint="Microsoft.SharePoint.WebControls" xmlns:ddwrt2="urn:frontpage:internal" xmlns:o="urn:schemas-microsoft-com:office:office"> <xsl:include href="/_layouts/xsl/main.xsl"/> <xsl:include href="/_layouts/xsl/internal.xsl"/> <xsl:param name="AllRows" select="/dsQueryResponse/Rows/Row[(position() >= $FirstRow and position() <= $LastRow)]"/> <xsl:param name="dvt_apos">'</xsl:param> <!-- Customize the hyperlink rendering for doc libraries --> <xsl:template match="FieldRef[@Name='LinkFilename']" name="LinkFilenameNoMenu.LinkFilename" mode="Computed_LinkFilename_body" ddwrt:tag="a" ddwrt:dvt_mode="body" ddwrt:ghost=""> <xsl:param name="thisNode" select="."/> <xsl:param name="ShowAccessibleIcon" select="0"/> <xsl:param name="folderUrlAdditionalQueryString"/> <xsl:param name="IncludeOnClick" select="1"/> <xsl:choose> <xsl:when test="$thisNode/@FSObjType='1'"> <xsl:choose> <xsl:when test="$RecursiveView"> <xsl:value-of select="$thisNode/@FileLeafRef" /> </xsl:when> <xsl:otherwise> <xsl:variable name="FolderURL"> <xsl:value-of select="$PagePathFinal" />RootFolder=<xsl:value-of select="$thisNode/@FileRef.urlencode" /><xsl:value-of select="$ShowWebPart"/>&FolderCTID=<xsl:value-of select="$thisNode/@ContentTypeId" />&View=<xsl:value-of select="$View"/><xsl:value-of select="$folderUrlAdditionalQueryString"/> </xsl:variable> <xsl:choose> <xsl:when test="$IsDocLib"> <xsl:variable name="OnMouseDownJS"> javascript:VerifyFolderHref(this,event,'<xsl:value-of select="$thisNode/@File_x0020_Type.url" />','<xsl:value-of select="$thisNode/@File_x0020_Type.progid" />','<xsl:value-of select="$XmlDefinition/List/@DefaultItemOpen" />','<xsl:value-of select="$thisNode/@HTML_x0020_File_x0020_Type.File_x0020_Type.mapcon" />','<xsl:value-of select="$thisNode/@HTML_x0020_File_x0020_Type" />','<xsl:value-of select="$thisNode/@serverurl.progid" />');return false; </xsl:variable> <xsl:variable name="OnClickJS"> return HandleFolder(this,event,"<xsl:value-of select="$PagePathFinal" />RootFolder=" + escapeProperly("<xsl:value-of select="$thisNode/@FileRef" />") + '<xsl:value-of select="$ShowWebPart" />&FolderCTID=<xsl:value-of select="$thisNode/@ContentTypeId" />&View=<xsl:value-of select="$View" /><xsl:value-of select="$folderUrlAdditionalQueryString"/>','TRUE','FALSE','<xsl:value-of select="$thisNode/@File_x0020_Type.url" />','<xsl:value-of select="$thisNode/@File_x0020_Type.progid" />','<xsl:value-of select="$XmlDefinition/List/@DefaultItemOpen" />','<xsl:value-of select="$thisNode/@HTML_x0020_File_x0020_Type.File_x0020_Type.mapcon" />','<xsl:value-of select="$thisNode/@HTML_x0020_File_x0020_Type" />','<xsl:value-of select="$thisNode/@serverurl.progid" />','<xsl:value-of select="$thisNode/@CheckoutUser.id" />','<xsl:value-of select="$Userid" />','<xsl:value-of select="$XmlDefinition/List/@ForceCheckout" />','<xsl:value-of select="$thisNode/@IsCheckedoutToLocal" />','<xsl:value-of select="$thisNode/@PermMask" />'); </xsl:variable> <a onfocus="OnLink(this)" href="{$FolderURL}"> <xsl:choose> <xsl:when test="$IncludeOnClick = '1'"> <xsl:attribute name="onmousedown"> <xsl:value-of select="$OnMouseDownJS"/> </xsl:attribute> <xsl:attribute name="onclick"> <xsl:value-of select="$OnClickJS"/> </xsl:attribute> </xsl:when> </xsl:choose> <xsl:value-of select="$thisNode/@FileLeafRef" /> <xsl:choose> <xsl:when test="$ShowAccessibleIcon"> <img src="/_layouts/images/blank.gif" class="ms-hidden" border="0" width="1" height="1" alt="{$idPresEnabled}" /> </xsl:when> <xsl:otherwise></xsl:otherwise> </xsl:choose> </a> </xsl:when> <xsl:otherwise> <xsl:variable name="OnClickJS"> javascript:EnterFolder("<xsl:value-of select="$PagePathFinal" />RootFolder=" + escapeProperly("<xsl:value-of select="$thisNode/@FileRef" />") + '<xsl:value-of select="$ShowWebPart" />&FolderCTID=<xsl:value-of select="$thisNode/@ContentTypeId" />&View=<xsl:value-of select="$View" /><xsl:value-of select="$folderUrlAdditionalQueryString" />');return false; </xsl:variable> <a onfocus="OnLink(this)" href="{$FolderURL}"> <xsl:choose> <xsl:when test="$IncludeOnClick = '1'"> <xsl:attribute name="onclick"> <xsl:value-of select="$OnClickJS"/> </xsl:attribute> </xsl:when> </xsl:choose> <xsl:value-of select="$thisNode/@FileLeafRef" /> <xsl:choose> <xsl:when test="$ShowAccessibleIcon"> <img src="/_layouts/images/blank.gif" class="ms-hidden" border="0" width="1" height="1" alt="{$idPresEnabled}" /> </xsl:when> <xsl:otherwise></xsl:otherwise> </xsl:choose> </a> </xsl:otherwise> </xsl:choose> </xsl:otherwise> </xsl:choose> </xsl:when> <xsl:otherwise> <a href="{$thisNode/@FileRef}" target="new"> <xsl:value-of select=$thisNode/@FileLeafRef.Name /> </a> <xsl:if test="$thisNode/@Created_x0020_Date.ifnew='1'"> <xsl:call-template name="NewGif"> <xsl:with-param name="thisNode" select="$thisNode"/> </xsl:call-template> </xsl:if> </xsl:otherwise> </xsl:choose> </xsl:template></xsl:stylesheet>
This is essentially a full copy of the snippet found in fldtypes.xsl with a slightly different template signature and some additional pre-requisites up in the header region that make this work for overriding the rendering of any document libraries which are configured to reference this as their transform... happy programming! - BW