开发者

What is a global SharePoint file included on all pages that I can easily embed JS?

The issue is that I've written a simple piece of JS that allows for some functionality that must be present on all pages. I've tried including it in /_catalogs/masterpage/default.master and I have found that it is not开发者_如何学编程 being called for the search results page.

The basic requirement as three core requirements:

  1. The include must only happen in one place within SharePoint - we cannot track and maintain multiple touch-points in the SharePoint code.
  2. The target file to be modified should exist for both 2007 and 2010 - I need to be able to provide instructions on where to include my code for users on both platforms.
  3. The code can't go in core.js or any other file that can't be modified by users on the hosted platform.

I've tried a number of different resources to figure this out, but I'm not a SharePoint guy, and trying to wrap my head around this architecture is quite daunting.


Try your options from here. On same blog, it is mentioned what was the best approach for SharePoint 2007 as well.

http://weblogs.asp.net/jan/archive/2010/03/01/scriptsrc-referencing-javascript-files-with-sharepoint-2010-custom-actions.aspx


It sounds like you're close. By default a search site will not have the Publishing Feature turned on to use a master page. If you enable the Publishing Feature from the Site Features on the Search site then you can set the masterpage for the Search to be the same as your other sites. That would allow your javascript to be run on the search pages too.

If you cannot change the masterpage setting for the search site then you may need to add your code into both places (optionally referencing one central file from both). But the masterpage is a good central place for code like this. It's just a matter of getting the code in all of the masterpages that are used.


Have you had a look at the free SharePoint Infuser? SP2007 only, but an SP2010 will be released as well.

Basically it allows injecting of any HTML / CSS / JS on all pages in a site collection without modifying them.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜