Open HTML files in browser - SharePoint Online

Copper Contributor

I'm trying to open HTML files that are saved in a Document Library created on a Team site (using Office 365 Groups). When we add HTML files to the library they will only download and then open. We would like to be able to have these files open in the browser. Any ideas? 

42 Replies

Hello @Melissa Klug,

 

I know this thread is a little bit older, but I stumbled over this while looking for a solution for the same issue. With several try and errors, I finally got a solution that might help you.

 

What you will need, is a tenant admin and a bit of PowerShell code. So let me describe the few steps necessary:

1) Login to your SharePoint Tenant via SharePoint Online Management Shell with 

Connect-SPOService

2) Execute 

Set-SPOSite -Identity https://[yourtenant].sharepoint.com/[siteurl] -DenyAddAndCustomizePages 0

 

After this execution, you will get the Content Editor WebPart available in the WebPart Section and you will be able to include your HTML page inside a Default aspx page of SharePoint.

 

While I was still experiencing the Problem, that I cannot navigate to a html page inside a library, I was able to create a folder on the root of the site when connecting via SharePoint Designer. After placing a html file here, I was able to navigate to it. Since I did some try and error in advance, you may need to enable the publishing feature too, but I cannot tell if this is really necessary.

 

Cheers, Tim

-- Updated... now with Format :xd:

@AaronMi Thanks.  Even if I had a PhD from MIT to be able to perform this (yes, or watching a video would help), I do not have the administrative priviliges necessary to execute this.  Nor will my IT department help me.  They either don't know how to do it themselves, or they refuse to help, believing that my needs are too trivial to bother with.  Hence the workaround where I literally cut and paste a page at a time into wiki pages and redirected every single link by hand.

 

I was just hoping that there was a simple "switch" to set to "permissive" being that I created these simple pages myself, and -- while not a luddite by any stretch -- am not up to creating malware which will blow up the internet.

 

Just hoping that before the powers that be decide to pull the rug out from under me again, I can simply "migrate" my files rather than rebuild them one at a time.  After all, I thought technology was supposed to make things easier for lowly peons like me....not so much anymore.

 

However, I will keep a copy of this.

@MothraMoon 

 

I am having the same problems.  I have some scenarios built in eLearning which are simple html5 files, and I want staff to be able to simply click on the index file to open.

 

Has ANYONE found a simple NON technical way of doing this?

 

Thanks

Schelle

@Melissa Klug I have done this. I uploaded the html files to  a document library.

Then I used sharepoint designer to access this document library and renamed all the html extension to aspx. If there is references with some html files to other html files sharepointdesigner will rename these references when changing the file extension to aspx. In fact, I uploaded an entire html site to document library, about 160 pages and had it working within sharepoint in 20 minutes.

@victormonasterio 

 

Hi Victor,

I am so sorry to ask, but where is SharePoint Designer?

I have screen shot the menu in SharePoint (attached) and the only thing is Design Manager, what am I missing :sad:

 

@SchelleT Sharepoint designer is a separate application. You can download here https://www.microsoft.com/en-au/download/details.aspx?id=35491

 

@victormonasterio 

Thanks, I will download it :smile:

@MothraMoon  PS, and I should mention....if you go through all the effort to create the wiki pages, you need to remember to "Publish" them or the people in your organization who do not have administrative priviliges will not be able to see them.  Since I created the site I could see them just fine, I only became aware of this when a student tried to click on the pages and they would not open.

@Melissa Klug   I've just joined to look for a solution to exactly the same problem. 

i've had a small win using File Viewer to show a html5 page. 

 

I uploaded the html file that i wanted to show into a Documents folder, and then set up a new site page with a File Viewer web part.  When the page is published, the html file opens fine in the File Viewer window.  The hyperlinks (to external links) in the html page are active and seem to pop out and open up with a normal browser.  I haven't tried it yet to open another html file in the same doc folder though.

 

 

@Deleted 

Thanks for the solution.

in Sharepoint online site,I changed my video file from .htm to .aspx and it is working as well,but in same time the blank.htm file is also downloaded,how can we prevent this downloading,please suggest.

Hi @Dvik_11 - I don't have a suggestion for the blank.htm download file you're seeing.  We haven't seen that with ours.

@Melissa Klug Try to give some more permission like adding to Owners group or site collection admin. This solved my problem. Thanks

 

For those of us who are still onpremise.
Add the html mime type to the WebApplication in SharePoint and use a document library in classic mode. Not sure if Microsoft let's you do this in SharePoint Online.

You can use the script to add any mime type.

Add-PSSnapin Microsoft.SharePoint.PowerShell -ErrorAction SilentlyContinue

$webApp = https://yoursitename.com

function Add-SPAllowedInlineDownloadedMimeType{

[CmdLetBinding()]

param(

[Parameter(Mandatory=$true, Position=0, ValueFromPipeLine=$true)]

[Microsoft.SharePoint.PowerShell.SPWebApplicationPipeBind]$WebApplication,

[Parameter(Mandatory=$true, Position=1)]

[string]$MimeType

 

)

process{

$actualWebApp = $WebApplication.Read()

if ($actualWebApp.AllowedInlineDownloadedMimeTypes -notcontains $mimetype)

 

{

Write-Host "Adding MIME Type..."

$actualWebApp.AllowedInlineDownloadedMimeTypes.Add($mimetype)

$actualWebApp.Update()

Write-Host "Done."

} Else {

Write-Host -ForegroundColor Green "MIME type is already added."

 

}

}

}

Add-SPAllowedInlineDownloadedMimeType -WebApplication $webApp -MimeType "text/html"

 

@Melissa Klug

Hello - I also had this issue and the workaround I came up with is uploading all html assets with the index.html to a document library, then opening the file library contents in "Open with Explorer" mode on SharePoint, open the index.html from here and you will notice a different address in the address bar, use this link instead and it will work! @Melissa Klug 

Thanks Melissa, will give it a go.

@LiasGallardo 

I saw you response on how you opened HTML5 video file on SP 365. I also have a training created in Articulate Story which is in html format. when I change the extension to .aspx then it doesn't work. Am I doing it correct? Thanks in advance for your help.

Changing the  ".html" to ".aspx" gave me the following: 

Murray50_0-1621007720022.png

Is there a way to NOT offer the Download option? This is a link to a video within training, I don't want them to be able to download the video.

@Murray50 @Melissa Klug 

This Microsoft article explains that you have to change some site settings and use PowerShell to effectively rename a .html file to .aspx. It also says that if you subsequently edit the file it will no longer open directly until you go through the process again. The whole purpose is to stop malicious code from being inserted on the SharePoint site and run via .html pages. https://docs.microsoft.com/en-us/sharepoint/dev/solution-guidance/security-permissivesetting#remedia...

Just use classic view... click Return to classic SharePoint.