views:

35

answers:

3

Hello all

I've a business requirement in which i need to create a SharePoint feature which registers a JavaScript across all the SharePoint pages.

The only way i figured out to achieve it is that adding the script in (all) the SharePoint Master Pages or any other custom master pages present in the Site/Site Collection/Web Application while activating the feature.

But i found that editing the master pages to add a Javascript snippet is not feasible.

Finally i found that i could register my custom controls in the "Delegate Controls" and the custom user control i created can in turn register my script in the page.

But my question is how can i handle it if the master page does not have a delegate control?

Or is there any other possible solution to register a script across all the SharePoint pages?

A: 

You can use the free SharePoint Infuser tool to achieve this.

If you have a master page that does not have a delegate control then add it if possible.

Muhimbi
+4  A: 

The AdditionalPageHead Delegate Control should be on every out-of-the-box master page in SharePoint 2007. Check out this article. It is specifically about jQuery, but it covers good practices concerning attaching scripts.

The only remaining kinds of master pages will be all of your custom master pages, which I would assume you have access to. Now, we've already ruled out directly adding the script to the master page (since it is a bad idea), so what should be done is adding the Delegate Control. The following would suffice.

<SharePoint:DelegateControl runat="server" ControlId="AdditionalPageHead" AllowMultipleControls="true" />

In all of the out-of-the-box master pages, this is in the section, at the very end. That would be the best place to put it in your custom master pages. There is no real disadvantage to including the Delegate Control in your master page, so it would be best to make it a practice to include that when you create new master pages.

ccomet
A: 

you can use this codeplex code for this

http://smarttools.codeplex.com/wikipage?title=jQuery&amp;referringTitle=Home

Try this link.

vipin Paliwal