0

i am working on a team site inside my SharePoint server 2013. I need to add a Java script code to my master page , so that the script will be available to all my SharePoint web pages. but i can not figure out where i should add the script to my master page ? and should i added it to the Seatle.master or other mater pages . any advice ?

John John
  • 1
  • 44
  • 241
  • 563

1 Answers1

1

Create a JS File und put following line inside the <head> element:

<SharePoint:ScriptLink language="javascript" name="custom.js" runat="server"/>

And yes seattle.master is the right place for it, if you want to run your JS Code on non-administrative pages.

To learn how to provide Custom Javascript files to SharePoint have a look here: more detailed explanation.

wu5chl
  • 53
  • 5
  • so i create a Script file named "custome.js" and then i upload it to my site assets, or where i should create the custome.js script file ? – John John Sep 03 '13 at 11:08
  • If you only need it in your site collection, you could put it into a document library at the root site collection. For example http://[host]/Scripts/.

    But be aware, that other users may access this library.

    Another possibility is to place into the file system under C:\Program Files\Common Files\microsoft shared\Web Server Extensions\15\TEMPLATE\LAYOUTS\.

    For better management you can create a subfolder here to encapsulate your assets.

    – wu5chl Sep 03 '13 at 11:12
  • i have added <SharePoint:ScriptLink language="javascript" name="custom.js" runat="server"/> after m , and i added the cusotm.js insdie the template\layouts but doing so will show black pages for all my site collection pages ... – John John Sep 03 '13 at 11:36