Insert JavaScript into a Content Editor Web Part (CEWP)

In the 2007 version of SharePoint, we had the Source Editor included in the Content Editor Web Part as our way of inputting JavaScript directly onto a page. The process on how to do this has changed a little bit in the new 2010 version. Follow below on how to successfully perform the same task.

Instead of having a Source Editor to directly paste in our code, we need to first create a simple text file and paste and save our code there. Once saved, upload that file to SharePoint. I am using the Site Assets library for this demo and a JavaScript that displays today’s date. After you have uploaded the file, right-click on the file and select Copy Shortcut.

Now, go to your desired page and put the page in edit mode. Add in the Content Editor Web Part located under the Media and Content category. Once added select the web part and use the ribbon UI to navigate to the Web Part Properties screen.

On the web part properties screen, paste in the URL link to your uploaded JavaScript file. Click Ok on the properties screen and, if your JavaScript is valid, it should display the desired results! Simple and easy!

Ref : Insert JavaScript into a Content Editor Web Part By sptwentyten

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s