4

In sharepoint 2010, I want to add javascript to the alerts popup window page, but I don't want to modify the actual layouts file. I want to dynamically insert javascript in it. Basically the button to open the window is through a sharepoint function called NewItem2. I need a reference to that window if I want to add a script tag to it. I was thinking of modifying the function so that it returns the id to the window. However I cannot find where the function is.

Can anyone help please? Thanks

1

If I'm not wrong you can find this function into C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\14\TEMPLATE\LAYOUTS{LCID} folder. There is the init.js and init.debug.js. Of course, you will have these files for each language that is installed to your environment.

But I do not recommend you to make changes in these files, because these files are used for all web applications, and can be overridden by SharePoint upgrade.

You can try to use solution like this.

1

It is not good practice for many reasons to modify out-of-the-box SharePoint files, the most obvious being that this type of customization is officially unsupported. For details please follow, for example this article.

In your scenario there are at least 2 ways how to provide additional client side functionality for Alert dialog:

  • Override NewItem2 function (details) But in that approach the SharePoint out-of-the-box javascript files are not being modified. The example of usage of this technique in SharePoint could be found here
  • Inject custom functionality (server and client side) via Delegate Control. More details about customizing Alert dialog using this technique could be found here

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.