question

PrateekSinha-5125 avatar image
0 Votes"
PrateekSinha-5125 asked ·

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

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.

office-sharepoint-online
10 |1000 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

1 Answer

AmosWu-MSFT avatar image
0 Votes"
AmosWu-MSFT answered ·

Hi @PrateekSinha-5125,
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.


image.png (14.0 KiB)
· 6 ·
10 |1000 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

The iframe has the script tag which is not loading and giving the above mentioned issue.

0 Votes 0 ·
AmosWu-MSFT avatar image AmosWu-MSFT PrateekSinha-5125 ·

Could you share the statement in your embed web part and the specific content of the page to help me reproduce your issue?

0 Votes 0 ·

I am unable to upload the code here but the idea is simple
That the iframe contains the code to load the js file.

Which is not working

0 Votes 0 ·
Show more comments