1

Am using SP.UI.ModalDialog.showModalDialog to open popup modal window. A custom anchor for closing using self.close and window.close without luck and no error found in console log.

function modalPopHwnd(targetURL, xwidth) {
    var options = {
           url: targetURL,  width: xwidth,
};
SP.SOD.execute('sp.ui.dialog.js', 'SP.UI.ModalDialog.showModalDialog', options);   
}//.the modal window

<a onclick="modalPopHwnd('/_layouts/CopyUtil.aspx?Use=id&amp;Action=dispform&amp;ItemId=6&amp;ListId=8c103834-48d8-4e0b-a5d2-59b04cd61aa7&amp;WebId=29d8af83-b455-4c39-ab1b-7517b3ea3ced&amp;SiteId=9af8b4f2-01b3-49fd-bbed-130f4f93b8e1&amp;Source=http%3A%2F%2Fportal%2FPages%2FHomepage%2Easpx', 560)" class="anchorOrange12">News Title</a>

Any idea? TIA.

Jonathan.B
  • 85
  • 1
  • 10

2 Answers2

2

Try following. It's being used in one of my project for closing SP.UI.ModalDialog.showModalDialog.

var closeModalDialog = function () {
                SP.SOD.executeFunc('sp.js', 'SP.ClientContext', function () {
                    SP.UI.ModalDialog.commonModalDialogClose(1, 1);
                });
            };

Update to the first comment: Where to place the above code? You have mentioned that you have custom anchor. So add onclick in your custom anchor like following

<a id="closeModalDialog " onclick="closeModalDialog ()">Close Modal</a>
Atish Kumar Dipongkor
  • 13,371
  • 5
  • 32
  • 64
0

In case you need the sample:

 <div class="dvClose" onclick="javascript:closeModalDialog ();">some text here</div>

Thanks to the contributor.

Jonathan.B
  • 85
  • 1
  • 10