Sharepoint - Object # has no method 'showModalDialog' in chrome

 Consider the following code:
function ShowWelcomeDialog() {
    var data = {};

    var options = {
        url: "/_layouts/xxxx/xxxxxss.aspx",
        title: "xxx xxx",
        width: 700,
        height: 950,
        dialogReturnValueCallback: myDialogCallback,
        args: JSON.stringify(data)
    };

    SP.UI.ModalDialog.showModalDialog(options);
    return false;
}
 I have this code for a button click and the modal opens fine in firefox and ie. But it doesn't open in Chrome. It gives the following error in console:
Uncaught TypeError:Object # has no method 'showModalDialog'..
 Solution:

Replace the line:
SP.UI.ModalDialog.showModalDialog(options);
with
SP.SOD.execute('sp.ui.dialog.js', 'SP.UI.ModalDialog.showModalDialog', options);



StackOverFlow
SHARE

Vikas Kottari

Hi. I’m a SharePoint Developer. I’m Microsoft Certified Professional on SharePoint. I work on O365, SharePoint 2016/2013/2010, SPFx and also I’m Full stack .NET Developer. I’m Foodie, Dreamer and Photographer. Inspired to make things looks better.