How to add HTML to sharePoint online

Copper Contributor

Hi 

 

how do i add HTML code and JavaScript to SharePoint online

6 Replies

@Molete depending on what you're trying to achieve they may be several options. I strongly advice you to go through SharePoint development overview documentation to get a better picture of what is possible https://docs.microsoft.com/en-us/sharepoint/dev/general-development/sharepoint-development-overview

@Molete 

Seems difficult and didn't work with the suggested ways. But somewhere, I found a solution which worked very well: Upload all the files and folders used in the html site to a SP library, keeping the same structure. Open the startpage in an editor > save it as .aspx file > upload this .aspx to the SP library in the folder where you have the .html file. The .aspx can be opened from SP and the links will be ok.

@Molete 

 

If you're on classic pages, you can add a Content Editor Web Part which points to your HTML file, which in turn loads your JavaScript files.

 

You can:

- Create an SPFx web part that does what you need

- Create an SPFx single part app page that does what you need

- Use @Mikael Svenson's SPFx Script Editor web part: https://github.com/SharePoint/sp-dev-fx-webparts/tree/master/samples/react-script-editor


@Thomas Berman wrote:

@Molete 

 

If you're on classic pages, you can add a Content Editor Web Part which points to your HTML file, which in turn loads your JavaScript files.

 

On modern pages, you can:

- Create an SPFx web part that does what you need

- Create an SPFx full page application

- Use @Mikael Svenson's SPFx Script Editor web part: https://github.com/SharePoint/sp-dev-fx-webparts/tree/master/samples/react-script-editor


The proper way is to create a new SPFx webpart with the html/script. There are many security reasons why using my web part or the the old classic ones are a bad idea.

Just to be clear before you go any which way just because you can :grinning_face:

@Mikael Svenson Hi I am trying to add a tab menu on my SP page, on Modern SP, do I need  to do all this just to add that?  below

On modern pages, you can:

- Create an SPFx web part that does what you need

- Create an SPFx full page application

- Use @Mikael Svenson's SPFx Script Editor web part: https://github.com/SharePoint/sp-dev-fx-webparts/tree/master/samples/react-script-editor

 

What do you want to accomplish in terms of tab UX and what happens when you click them. First evaluate existing web parys in SharePoint Online. Next look at open source samples at https://pnp.github.io/sp-dev-fx-webparts/. As a last resort maybe the script editor web part (part of the samples).

 

All part of ROI.