Search code examples
javascripthtmlcsssharepointweb-parts

How to add a inline JS/HTML code in a sharepoint web part


I'm currently trying to costimize my bot that is embedded in my sharepoint web site. for this i need to add the code below in a web part or at least the link and the .

<html>
  <head>
    <link href="https://cdn.botframework.com/botframework-webchat/latest/botchat.css" rel="stylesheet" />
  </head>
  <body>
    <div id="bot"/>
    <script src="https://cdn.botframework.com/botframework-webchat/latest/botchat.js"></script>
    <script>
      BotChat.App({
        directLine: { secret: 'YOUR_DIRECT_LINE_SECRET' },
        user: { id: 'USER_ID' },
        bot: { id: 'YOUR_BOT_ID' },
        resize: 'detect'
      }, document.getElementById("bot"));
    </script>
  </body>
</html>

Can someone help me please ?

PS: i really don't know much about sharepoint but i know that the version of sharepoint user is the last one.


Solution

  • You can Use Content Editor Web Part.

    follow below steps:

    1. Create your JS file in SharePoint designer and put your html and JS code here.

    2. Open the page in browser where you want to add this code

    3. Click on edit page from the gear icon present at the top right corner. enter image description here

    4. On ribbon click on Insert >> Under category select Media and content >> select content editor web part and click Add.

    5. click on the triangle present at the right corner of content editor web part and click on edit web part.

    6. Add the link of your JS file and click on Test. enter image description here

    7. Click Apply and OK

    8. From the ribbon click Save and then stop editing.