Forum Discussion
Weird behavior for adding "embed code" inside our classic pages and inside application pages
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?
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?
- AnonymousJan 17, 2019John, from my understanding, that option gives you the ability to enable custom script on your site. Turning it on will not automatically give all sites the ability to run custom scripts. Instead, it gives site owners the ability to turn on custom scripts on their site.
However, if I remember correctly, you need to run some command lines in the Powershell to enable custom scripts in a site, and only admins can run powershell commands. That means if you are the only admin of the tenant, no one will be able to enable custom scripts other than you. Again, I am not sure if this is still true or if there is another way to enable custom script, but I believe turning that on is the only way to go if you want them in your site.- john johnJan 17, 2019Iron Contributor
Deleted wrote:
John, from my understanding, that option gives you the ability to enable custom script on your site. Turning it on will not automatically give all sites the ability to run custom scripts. Instead, it gives site owners the ability to turn on custom scripts on their site.
However, if I remember correctly, you need to run some command lines in the Powershell to enable custom scripts in a site, and only admins can run powershell commands. That means if you are the only admin of the tenant, no one will be able to enable custom scripts other than you. Again, I am not sure if this is still true or if there is another way to enable custom script, but I believe turning that on is the only way to go if you want them in your site.i think "custom scripts" setting in sharepoint ,, is very confusing and even reading the documentation does not cover all the cases...