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

2 Answers 2


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.


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 agree to our terms of service and acknowledge you have read our privacy policy.

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