Search code examples
javascriptgoogle-chromesharepoint-2010

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'..

Can anybody help me on this... Thanks in advance..


Solution

  • You could try to utilize SP.SOD.execute(key, functionName, args) Method in order to point function SP.UI.ModalDialog.showModalDialog to be executed from file sp.ui.dialog.js

    Replace the line

    SP.UI.ModalDialog.showModalDialog(options);
    

    with the

    SP.SOD.execute('sp.ui.dialog.js', 'SP.UI.ModalDialog.showModalDialog', options);