SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

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 have a portal's home page and on that page I want to put this but Its not allowing me to put this address and treating this as invalid address..I tried putting the following statement by EDIT HTML but when the page comes its not clickable. How to add this? ok ive added the suggested line but on click nothing is is what i have in my masterpage. and I also tried what you suggested

<a href="#" onclick='javascript:openDialog('/SitePages/NewReq.aspx');'>New Requisition</a>

well when i click the link nothing happens. I have the following in my masterpage.

<script type="text/javascript">
    //User Defined Function to Open Dialog Framework
    function OpenDialog(strPageURL)
      var dialogOptions = SP.UI.$create_DialogOptions();
      dialogOptions.url = strPageURL;// URL of the Page
      dialogOptions.width = 750; // Width of the Dialog
      dialogOptions.height = 500; // Height of the Dialog
      dialogOptions.dialogReturnValueCallback = Function.createDelegate( null, CloseCallback); // Function to capture dialog closed event
      SP.UI.ModalDialog.showModalDialog(dialogOptions); // Open the Dialog
      return false;
share|improve this question
up vote 1 down vote accepted

You don't write the javascript function call in href, instead use onclick event handler as shown below:

<script type="text/javascript">
function demoCallback(dialogResult, returnValue)
     SP.UI.Notify.addNotification('Operation Successful!');

function OpenMyDialog(strPageURL)
   //Using a generic object.
   var options = {
     title: "My Dialog Title",
     width: 750,
     height: 500,
     url: strPageURL,
     dialogReturnValueCallback: demoCallback };



<a href="#" onclick="javascript:OpenMyDialog('/SitePages/NewReq.aspx');">New Requisition</a>

This should work!

share|improve this answer
see my updated question – user342944 Dec 10 '12 at 14:51
when i opened the source of the page where ive put the link in it shows <br> <p><a href="/SitePages/Home.aspx#">New Requisition</a></p> – user342944 Dec 10 '12 at 14:53
Updated the answer, make sure you put the script and anchor tag exactly the same as given! – Arsalan Adam Khatri Dec 10 '12 at 21:46

To me, your code looks right but your casing in the function call isn't accurate.

It should be:

<a href="#" onclick='javascript:OpenDialog('/SitePages/NewReq.aspx');'>New Requisition</a>
share|improve this answer
i have problems putting this hyperlink. In browser if I edit the page and edit html and place this somewhere it shows the text but not clickable. If i try to place it by INSERT HYPERLINK through menu it simply doesn't accept the url. humm now what. – user342944 Dec 10 '12 at 18:58
my problem is this..look at this blog.… – user342944 Dec 11 '12 at 8:03

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.