Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

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.

share|improve this question
add comment

5 Answers

up vote 2 down vote accepted

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

share|improve this answer
    
@Nigel: html source editor button –  Julie May 27 '11 at 5:27
    
@Julie It didn't click with me that you are using SP2010. I found this link that should help: sptwentyten.wordpress.com/2010/08/31/… –  Nigel Whatling May 27 '11 at 5:40
    
@Nigel: Thanks for sharing the link. I think the js is not resolving b/c the page or the cewp is blank. I dont even see any exclamation sign on the status bar. Is not even getting loaded b/c i turn on the developer tool from ie and those references r completely missing from the page. –  Julie May 27 '11 at 5:54
    
@Julie Are you trying to reference the file using a <script> tag within the Content Editor Web part or are you specifying the file as a content link as the article describes? –  Nigel Whatling May 27 '11 at 5:59
    
@Nigel: Actually, cewp is all blank. everything is in the text file. I clean the browser cache and now i can see the error through developer tool. its on <GetListItems , i didnot noticed any syntax error. –  Julie May 27 '11 at 6:17
show 2 more comments

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.

share|improve this answer
    
I saved the js in a file and made a reference in the cewp. I then reran or F5 the page. Nothing happened. so cranked one ie developer tool and noticed that those js files are not in the page. –  Julie May 27 '11 at 5:29
add comment

Instead of the CEWP try it with the Simple Form WebPart instead.

share|improve this answer
add comment

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.

share|improve this answer
add comment

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:

  • Using SharePoint Designer, browse to Site Assests.
  • Create a new HTM File (Call it what you want)
  • Stick your code etc in there and save it
  • Go back to your page and use a CEWP.
  • Add the Url (Relative) to your htm file in the Content Link section like so:

enter image description here

Save and you're done.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.