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

Comments

Popular posts from this blog

SharePoint Online (O365) OAuth Authentication | Authorizing REST API calls against SharePoint Online Site | Get Access token from SharePoint Online | Set up OAuth for SharePoint Online Office 365

SharePoint 2013 REST API Reference

Simple Risk Assessment Matrix table with resultant risk calculation

Kendo UI (Core JavaScript) grid Server Paging, Server Sorting and Server Filtering with Dynamic SQL queries

Sharepoint- Using an Image From formatmap32x32.png in a Ribbon Control