Open a page in SharePoint Modal Dialog

I had a requirement to open a page in modal dialog and I used the following script for this.


<script type="text/javascript">
function ShowDialog(url)
{
   var siteWebUrl = _spPageContextInfo.webServerRelativeUrl;
   var options = SP.UI.$create_DialogOptions();
   options.url = siteWebUrl+"/"+url;
   /*options.height = 300;*/
   SP.UI.ModalDialog.showModalDialog(options);
}
</script>

<p>
<a class="ms-addnew" onclick="javascript:ShowDialog('/Lists/UserSubscription/NewForm.aspx?RootFolder=&IsDlg=1')" href="javascript:void(0)">Subscribe</a>
</p>

Comments

Popular posts from this blog

Switch from Classic to Claims Authentication in SharePoint 2010

How to query list data using web service