none
alternative to scripts in reusable content RRS feed

  • Question

  • Hi All,

    We migrated a site from MOSS 2007 to SP 2010 using DB upgrade. The 2007 site has a lot of reusable content with scripts used in the pages. These scripts don't work because SP 2010 strips out any javascript in page content or reusable content. To get these scripts working, we are thinking of putting these scripts in a content editor web part and using them in the pages. Can anyone suggest a better solution without involving much customization, where we can put the scripts in one place and use it across pages similar to reusable content?


    Amarnath

    Thursday, April 25, 2013 6:44 PM

Answers

  • Hi!

    Do you have alot of different scripts or just a coupe of .js files you want to include in every page? You could just edit the master page and add the js-files in there and you will have them in every page in the site. This is easiest if done in a publishing site because in a publishin site you can inherit the master page from a top level site to all subsite. But in teamsites you will need to edit every master page in every subsite. (or create a feature that links alla subsites to the same master page)

    Another way thay is a best practice to implement JavaScript and css files that should be included in every site is to create a Custom Control and add it to the Additional Page Header Delegate Control. Then you can activate a feature on the site Collection and every site in the site Collection will get the additionally JavaScript and css files. I Think you even could activate this on a web application or farm wide scope. This will need to be done in Visual Studio, but it's only a few lines of code.

    Here's an article showing you how to create this.
    http://www.sharepointnutsandbolts.com/2007/06/using-delegate-control.html

    There's also a free tool on codeplex that already created the addition page header for you and all you have to do is upload the javscript and css files in a Library in you site and they will be included in the pages.

    http://spsin.codeplex.com/

    Thursday, April 25, 2013 8:57 PM