SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm trying to write web-part for viewing list items. It contains link "add new item". I should create modal dialog for adding item, and it must work from every page.

So, I have JS for modal:

function openDialog(listUrl) {
    var options = SP.UI.$create_DialogOptions();

    options.title = "My Dialog Title";
    options.width = 400;
    options.height = 600;
    options.url = listUrl;


But it works only from list page. How can I fix it?

share|improve this question
could u share the parameters which u are sending... – Pushpendra Aug 21 '13 at 5:32

You can try with the below code using a Content Editor web part.

Copy the HTML markup from the existing Add new item link and use it.

Example :

<SPAN style="POSITION: relative; WIDTH: 10px; DISPLAY: inline-block; HEIGHT: 10px;    OVERFLOW: hidden" class=s4-clust><IMG style="POSITION: absolute; TOP: -128px !important; LEFT: 0px !important" alt="" src="/_layouts/images/fgimg.png"></SPAN>
<A id=idHomePageNewItem class=ms-addnew onclick='javascript:NewItem2(event, "http://{sharepointurl}/_layouts/listform.aspx?PageType=8&amp;ListId={}&amp;RootFolder=");javascript:return false;' href="http://{sharepointurl}/_layouts/listform.aspx?PageType=8&amp;ListId={}&amp;RootFolder=" target=_self>Add new item</A>

Paste the HTML markup into the Content Editor web part

Or, you can refer to the below link


share|improve this answer

First add the page you created the new web part to the Pages library. Lets assume the page name is Page1.aspx. Then in the page you need to add the link to it add it like this.

<a href="javascript:OpenPopUpPage('/Pages/Page1.aspx');">Page Popup</a>
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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