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.

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>
  • bit lost where to place the above code. Post updated with code am using. – Jonathan.B Nov 22 '15 at 12:02
  • call closeModalDialog function inside the onclick of your custom anchor – Atish Dipongkor - MVP Nov 22 '15 at 12:06
  • also add your html code @Jonathan.B – Atish Dipongkor - MVP Nov 22 '15 at 12:56
0

In case you need the sample:

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

Thanks to the contributor.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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