Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Sharepoint 2013 deleting contents of <style> in embed code when saving

I am trying to add some styling to a Sharepoint 2013 page using the Embed code facility. It works fine until I save the page and then it deleted all the text between the <style> and </style> tags?

So I click embed code on the page and enter the following

<style>
.sampleStyle {color:#fff}
</style>

When its saved and re-opened I find sharepoint has changed the code to this

<style unselectable="on">
</style>
like image 521
user3332229 Avatar asked Feb 20 '14 10:02

user3332229


People also ask

How to embed code in SharePoint 2013?

In SharePoint 2013 a new feature is introduced called Embed Code. It inserts an embedded object, HTML snippets or scripts onto the page. This SharePoint new feature is located in the ribbon when the user edits the page. Create a new page and insert the HTML and CSS to edit the page and embed a code tab into the page. Click on the Insert Tab in ...

Can I change the code once it is embedded in SharePoint?

When you first add the code you must use in order for SharePoint to save and embed some code. Once it's embedded, you can change it and it will remain embedded and work.

How to add CSS styles and JavaScript in SharePoint content editor?

When you first add the code you must use <script> in order for SharePoint to save and embed some code. Once it's embedded, you can change it and it will remain embedded and work. I think you can't add css styles and javascript in content editor. However, you can use script editor to add them.

How do I embed content on my website?

Copy the embed code (if available) for the content you want to use. To do this, go to the site with the content you want to embed. Somewhere near the content you will typically see a Share button or link, or a button labeled Embed code or </>.


Video Answer


2 Answers

It can be done. In my frustration this morning, I was adding information in the embed code box and SharePoint wouldn't save it at all. When I returned to the box, it was just empty.

Here's how to make it work:

  • Use embed code as before, but enter the following:

    <script type="text/css">
      */your CSS here/*
    </script>
    
  • Click Insert

  • Save your page
  • Edit your page again and change script to style (as it should be)

It'll now work!

When you first add the code you must use <script> in order for SharePoint to save and embed some code. Once it's embedded, you can change it and it will remain embedded and work.

like image 182
Alasdair Avatar answered Oct 24 '22 01:10

Alasdair


I think you can't add css styles and javascript in content editor. However, you can use script editor to add them.

Much better is to have a file and using script editor, include that file, like in video https://www.youtube.com/watch?v=gcWX3N4nWyw

like image 44
XristosK Avatar answered Oct 24 '22 01:10

XristosK