SharePoint – Use Javascript

Hello everyone. Today I want to show you how to use Javascript on your SharePoint websites.

To show you how this works I created a Javascript file which applies a CSS file to a SharePoint Page. Here are my scripts:


var path = "/Style Library/Custom";
var style = document.createElement('link');
style.rel = 'stylesheet';
style.type = 'text/css';
style.href = path + '/HideRecentlyModified.css';


display: none;

After I created those scripts I uploaded them to my SharePoint website.


Now add a Content Editor Webpart to the SharePoint Page you want to apply your Javascript file to.


Now start editing your Content Editor Webpart and click on Edit HTML Source to modify its HTML Code.


Now add the following code to the HTML Source window:

<script src="/Style Library/Custom/SwitchCSS.js"></script>


Now click on OK and save your changes. That´s it. This is all you need to do when you want to apply a Javascript file to your SharePoint pages. I hope my post was useful for you.


Tagged , ,

Leave a Reply

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

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

Google+ photo

You are commenting using your Google+ 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 )


Connecting to %s

%d bloggers like this: