Jan 10 2023 03:43 AM
I've some html code (with css) that I want to add to the page
I've tried uploading it to Site Assets as an aspx file, but it won't let me embed it.
I just need to do this as a quick one off and don't have time to do a full web part.
Is there an easy way I can just add it?
Jan 10 2023 05:57 AM
@Lee-Martin
"Disable Custom Scripting" is enabled per default on new sites because of security concerns. So custom ".aspx" files are always downloaded and not displayed.
To disable "Disable Custom Scripting" do the following:
1) Be a SharePoint Administrator (SiteCollection Admin is not sufficient)
2) Either connect with the SharePoint Management Shell to the SharePoint admin site (https://<tenant>-admin.sharepoint.com) and execute
Set-SPOSite <SiteURL> -DenyAddAndCustomizePages 0
3) Or connect with PNP Powershell to the SharePoint admin site (https://<tenant>-admin.sharepoint.com) and execute
Set-PnPSite -Identity <SiteURL> -NoScriptSite $false
(https://learn.microsoft.com/en-us/sharepoint/allow-or-prevent-custom-script)
Best Regards,
Sven
Jan 10 2023 07:47 AM
Jan 10 2023 11:51 PM
@Lee-Martin If you are trying to embed custom HTML/CSS/JS on modern pages, you can use Modern script editor web part developed using SPFx by community members.
This web part code is available at: Script editor web part for modern pages built in React
Please click Mark as Best Response & Like if my post helped you to solve your issue. This will help others to find the correct solution easily. It also closes the item. If the post was useful in other ways, please consider giving it Like.
Jan 11 2023 12:44 AM