Forum Discussion

Molete's avatar
Molete
Copper Contributor
Jun 14, 2019

How to add HTML to sharePoint online

Hi 

 

how do i add HTML code and JavaScript to SharePoint online

6 Replies

  • 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

    • Mikael Svenson's avatar
      Mikael Svenson
      Iron Contributor

      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 😀

      • Gladys Aguilera's avatar
        Gladys Aguilera
        Copper Contributor

        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

         

  • EliMar's avatar
    EliMar
    Copper Contributor

    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.

  • Djavan ROA's avatar
    Djavan ROA
    Brass Contributor

    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

Resources