Unable to import JavaScript external files in iFrame loaded into script editor via web-part SharePoint online

Prateek Sinha 1 Reputation point
2021-03-01T04:52:17.92+00:00

I am trying to load a custom JavaScript from an Iframe which is added to the sharepoint editor by using the script editor and adding it as a webpart code snippet.

I have followed the following steps:

Added html file in assets
Created a page in sharepoint online
In the edit mode clicked on “Embed code” webpart.
Added Iframe for the html file which contains link to add javascript and perform functions
I have also changed the following security options:

Enabled the add custom script in admin panel as directed in some of the posts.
The html field security to load iframes from any domain

I am getting only one error i.e.

Blocked script execution in 'about:srcdoc' because the document's frame is sandboxed and the 'allow-scripts' permission is not set sharepoint

Thanks in advance.

SharePoint
SharePoint
A group of Microsoft Products and technologies used for sharing and managing content, knowledge, and applications.
10,047 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Amos Wu-MSFT 4,051 Reputation points
    2021-03-02T02:30:06.76+00:00

    Hi @Prateek Sinha ,
    According to the official documentation, embed code that uses script tags is not supported.
    73202-image.png
    Reference:
    Add content to your page using the Embed web part
    If you want to use custom features on modern pages, I recommend you to use SharePoint Framework.


    If the response is helpful, please click "Accept Answer" and upvote it.
    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.