I am trying to follow this link and put all the code in a CEWP as suggested. After saving the page the code goes away (except for the gear part, top line).
I could really use some help if possible.
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It only takes a minute to sign up.
Sign up to join this communityI am trying to follow this link and put all the code in a CEWP as suggested. After saving the page the code goes away (except for the gear part, top line).
I could really use some help if possible.
I'm sorry if I'm stating the obvious here... but you are clicking the Source Editor button and not the Rich Text Editor button when editing the Web part aren't you?
For SP2010, see: http://sptwentyten.wordpress.com/2010/08/31/insert-javascript-into-a-content-editor-web-part-cewp
There is probably an error in the code which the CEWP is unable to save. You could save the JavaScript functions in another file and reference that file instead of placing all the code in the web part. You'll still need to debug it, but at least you'll be able to save the web part with just the script references and the call to the function.
Another option is to eliminate the CEWP and instead edit the Page Layout file in SharePoint Designer and insert your code there.
The safest and easiest way to do this is to not save the code directly in the web part. The CEWP is trying to be clever and strips tags out because it sees it as potentially dangerous. Rather do this:
Save and you're done.
I had a similar problem and I finally figured out what was happening. The problem occurred in pages that were created by the Sys Admin, not by me. If I created the page the Javascript code would not be stripped. Try that.