admin管理员组

文章数量:1323157

I'm trying to add jQuery to sharepoint 2013 master page. What I did:

1)

  • Copy jquery - "jquery-1.11.1.min.js" to C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\15\TEMPLATE\LAYOUTS.
  • Copy seattle.html and add <!--SPM:<SharePoint:ScriptLink language="javascript" name="/_layouts/jquery-1.11.1.min.js" runat="server" Localizable="false" />-->
  • Upload seattle.html as ASP NET MASTERPAGE
  • Publish it ---> Nothing happend. To seattle.master wasn't appear Sharepoint:Scriptlink

2)

  • Copy jquery - "jquery-1.11.1.min.js" to SiteAssets. My application is on root site collection so for instance access to jquery is

http://localhost/SiteAssets/jquery-1.11.1.min.js

  • Copy seattle.html
    • Add !--SPM:<SharePoint:ScriptLink language="javascript" name="'~sitecollection/SiteAssets/jquery-1.11.1.min.js" runat="server" Localizable="false" />-->
    • Still no effect

What is the correct way from begining to the add of adding Jquery to Sharepoint 2013?

I'm trying to add jQuery to sharepoint 2013 master page. What I did:

1)

  • Copy jquery - "jquery-1.11.1.min.js" to C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\15\TEMPLATE\LAYOUTS.
  • Copy seattle.html and add <!--SPM:<SharePoint:ScriptLink language="javascript" name="/_layouts/jquery-1.11.1.min.js" runat="server" Localizable="false" />-->
  • Upload seattle.html as ASP NET MASTERPAGE
  • Publish it ---> Nothing happend. To seattle.master wasn't appear Sharepoint:Scriptlink

2)

  • Copy jquery - "jquery-1.11.1.min.js" to SiteAssets. My application is on root site collection so for instance access to jquery is

http://localhost/SiteAssets/jquery-1.11.1.min.js

  • Copy seattle.html
    • Add !--SPM:<SharePoint:ScriptLink language="javascript" name="'~sitecollection/SiteAssets/jquery-1.11.1.min.js" runat="server" Localizable="false" />-->
    • Still no effect

What is the correct way from begining to the add of adding Jquery to Sharepoint 2013?

Share Improve this question asked Aug 14, 2014 at 9:54 AdrianXAdrianX 1631 gold badge7 silver badges17 bronze badges
Add a ment  | 

2 Answers 2

Reset to default 4

Probably you forgot to apply custom master page, go to Master Page settings page and set Site Master Page and System Master Page to your custom master page.

Note: there is a typo in the second option: name attribute contains ' symbol

How to reference JavaScript file in SharePoint 2013 master page

Assume the following scenario:

  • a custom master page helsinki.master with associated HTML file are used
  • jQuery library jquery.min.js is located in SharePoint Site Assets library

Then, in order to reference jQuery library in custom master page the following steps are used:

  • Open an associated HTML file helsinki.html
  • Insert the line <!--SPM:<SharePoint:ScriptLink language="javascript" name="~sitecollection/SiteAssets/jquery.min.js" runat="server" Localizable="false"/>-->
  • Publish helsinki.html
  • Go to Master Page settings page and set Site Master Page and System Master Page to helsinki.master

About System Master Page

System Master Page is used by administrative pages, lists, and document library views on this site

This approach has been tested in SharePoint 2013 and works for me.

i would suggest to add jQuery with a custom DelegateControl. With this approach there is no need to modify the MasterPage. Every Masterpage contains a placeholder where you are able to hook in custom scripts, like jQuery.

Here is a detailed description how to develop the solution: http://blogs.msdn./b/kaevans/archive/2011/04/06/adding-jquery-to-every-page-in-sharepoint-with-delegate-controls.aspx

The cool thing with the delegateControl is, that you can use any scopes for this Solution. So you can apply jQuery to the whole Farm, Webapplication, Sitecollection or Web.

Regards

本文标签: javascriptHow to add Jquery to MasterPage 2013Stack Overflow