Has anyone run into Sitecore removing JavaScript from the page editor?
Asked Answered
M

2

6

I've been working on a custom page in Sitecore over the holidays, and I've noticed an issue where Sitecore removes JavaScript lines from the editor.

Here's an overview of my current scenario:

  1. I add Javascript to the page.
  2. I save, check in, and publish.
  3. Changes are there, and everything is working.
  4. I work on it later and those changes are no longer there.

I'm the only one who's edited this page, and it is publishing the current/correct version. It doesn't matter if I add the script through the "Show Editor" or "Edit HTML" features of the content editor. It only removes the JavaScript though; all of my other changes are intact.

Is there something that I'm missing about Sitecore's implementation of JavaScript? I'm not sure what else to do in order to diagnose it, so I was hoping someone here would have an explanation for this.

Mystical answered 4/1, 2013 at 22:5 Comment(0)
O
15

Removing the script-tags in the RTE in Sitecore is standard behavior when the item is saved. However, in Sitecore 6.4.1 rev. 120113 and Sitecore 6.5 Update-4 there is a new property added in the web.config:

<setting name="HtmlEditor.RemoveScripts" value="true"/>

Setting this value to false should solve your problem. If you are using an older version of Sitecore, take a look at this blogpost which shows a workaround for older versions.

Ovida answered 5/1, 2013 at 16:35 Comment(5)
Hey, thanks for the reply. We are using 6.4.1 so I'll try adding this and see if it helps.Mystical
Hey Martijn, thanks again for the help. The code you supplied worked for editing with the plain text editor. Unfortunately it didn't help with the rich text editor, but I'm going to talk to our IT department to see if they can implement the changes suggested in the blog post. Thanks!Mystical
What is RTE exactly?Augmenter
This setting has been moved to sitecore.config in the latest sitecore versions <setting name="HtmlEditor.RemoveScripts" value="false"/>Kinross
@NicolasS.Xu RTE => Rich Text EditorShatterproof
D
3

Are you adding this javascript in a Rich Text Editor?

I've seen the rich text editor strip out javascript as it saves. We have typically added javascript blocks in as a separate sublayout pulling from a multi-line text field and having it render out directly, rather than editing javascript through the rich text editor.

Drabbet answered 4/1, 2013 at 22:44 Comment(3)
That's what we thought at first, but this behavior happens in both editors: the HTML tab on the Rich Text Editor as well as the Edit HTML plain text editor. Thanks for your reply!Mystical
@Jay Did you find a solution to it? Could you support your answer through screenshotsCreature
@Sidso: I'm sorry, but this was almost a decade ago... I don't have anything from that time anymore. My very rough memory of how we avoided this was to have users put JavaScript into a separate field, not a Rich Text field. However, there have been a LOT of changes in the platform between 2013 and now.Drabbet

© 2022 - 2024 — McMap. All rights reserved.