Forum Discussion
Weird behavior for adding "embed code" inside our classic pages and inside application pages
- john johnJan 17, 2019Iron Contributor
Deleted wrote:
Have you actually tried to insert script into the page? I remember my Sharepoint site would have this option available, but soon as I added the script tag to the box and hit Ok it would prompt me to a warning telling me I couldn't.Deleted
thanks a lot for the advice. now i created a classic page >> add "Embed code" , i got this 2 results:-
1. Inside the embed code i added pure HTML element, as follow:-
<h1 unselectable="on">test</h1>
and i were able to save the page without any issue.
2. While if i try to add a script element inside the "Embed code" as follow:-
<h1 unselectable="on">test</h1>
<script>
alert("123");
</script>i got this error:-
This HTML cannot be inserted because you don't have access to add scriptable Web Parts in this site. Please contact your administrator if you think you should have rights to do so.
so can i conclude that in my case i can add "embed code" web parts, but those "embed code" need to contain HTML only?
second question, so seem i do not have "custom scripts" enabled inside our communication site (since i was not able to add <script> tags inside the "embed code"). so can i enable the custom scripts for this communication site only, without having to affect the "custom scripts" settings inside other sites, or change the settings inside the sharepoint admin center site?
- AnonymousJan 17, 2019
so can i conclude that in my case i can add "embed code" web parts, but those "embed code" need to contain HTML only?
It cannot contain script, hence you will be not able to use the script tag in that code. I think you can still use other tags, such as the link tag to include CSS.
second question, so seem i do not have "custom scripts" enabled inside our communication site (since i was not able to add <script> tags inside the "embed code"). so can i enable the custom scripts for this communication site only, without having to affect the "custom scripts" settings inside other sites, or change the settings inside the sharepoint admin center site?
Yes, you can enable custom script for that site alone. But first, you need to allow users to runcustom script. Only then, you will be able to turn on custom scripting on your site. For more information, you can check http://sharepoint.handsontek.net/2018/10/28/enable-custom-script-on-modern-sharepoint-sites-using-powershell/
Regards
- john johnJan 17, 2019Iron Contributor
It cannot contain script, hence you will be not able to use the script tag in that code. I think you can still use other tags, such as the link tag to include CSS.
Deletedok noted. thanks
Yes, you can enable custom script for that site alone. But first, you need to allow users to runcustom script. Only then, you will be able to turn on custom scripting on your site. For more information, you can check this post.
but if i enable "custom scripts" from sharepoint admin center >> setting >>
then this will enable custom scripts inside all the current site collections and all future site collections, is this correct? while in my case i only need to enable it inside a single modern communication site, so is this possible and how?