Sunday 5 August 2012

How to add Javascript\Jquery in SharePoint 2013 site


One of the most questions asked in how to add Javascript\Jquery in SharePoint 2013 site. In Sp2013 you have many options to do this. Lets look at the options -


1. Script Editor WebPart - If you want to add Javascript\Jquery to a page in SharePointy you can use the "Script Editor WebPart". This is a special webpart added to insert HTML\JavaScript\Jquery to your site.

How to use this webpart - Edit a page and click on Webpart zone “Add a WebPart”. In the Ribbon under Insert select Add a webpart. In webparts windows “Script Editor” under Media and Content. Once the webPart is added click the “Edit Snippet” and add JavaScript in it.

2. JS Link - If you add a JavaScript function to a Listview\Dataview webpart without modifying the webpart in SharePoint designer, this is the option that you would love to use. MS has Introduced a new webpart property for Listview\Dataview webparts called "Js Link".

How to use this webpart - Add a listview webpart on page and then edit the webpart. In webpart ptoperties expand the last section “Miscellaneous” and scroll down. You would find “Js Link” as last option in Miscellaneous section.

3. Content editor WebPart - In addition to Script Editor WebPart you can still add javascript to this old and famous webpart editor webpart.

How to use this webpart - Edit a page and click on Webpart zone “Add a WebPart”. In the Ribbon under Insert select Add a webpart. In webparts windows add "Content Editor" under Media and Content. Next under Format text tab in Ribbon select "Edit Source" to add the javascript.


4.Adding JS to Master Page Custom Action - You can either manually mody your Mastre page and add Javascript or refence to it or simply use a Custom Action Feature to do this.

Ads by Google

No comments:

Post a Comment