Introduction
Have you ever tried using SP.UI.ModalDialog.showModalDialog(options) in SharePoint 2013? I discovered a strange behaviour.
After migrating my code from SharePoint 2010 to SharePoint 2013 the calls to showModalDialog failed with the message that the method cannot be found (JavaScript). When checking it in IE Developer Tools this isn't surprising at all. The required js-file isn't loaded.
But why? I guess it must be the new Script on Demand (SOD) Model that was introduced in SharePoint 2013.
SharePoint 2010 Example
- function ShowServerInformation() {
- var options = {
- url: '/_layouts/Management/GeneralInformation.aspx',
- tite: 'Management Information',
- allowMaximize: false,
- showClose: true,
- width: 430,
- height: 230
- };
- SP.UI.ModalDialog.showModalDialog(options);
- return false;
- }
Remove the Java Script reference.
- <script src="/_layouts/sp.js" type="text/javascript"></script>
- <script src="/_layouts/SP.UI.Dialog.js" type="text/javascript"></script>
- Add to the url variable "?IsDlg=1"`
- Replace the command SP.UI.ModalDialog.showModalDialog() with the new command
- SP.SOD.execute('sp.ui.dialog.js', 'SP.UI.ModalDialog.showModalDialog', options);
After this few changes your solution will work correctly.
SharePoint 2013 Example
- function ShowServerInformation(featureId) {
- var options = {
- url: '/_layouts/Management/GeneralInformation.aspx?IsDlg=1',
- tite: 'Management Information',
- allowMaximize: false,
- showClose: true,
- width: 430,
- height: 230
- }
I first tried the "executeOrDelayUntilScriptLoaded" function, but it was not much help. It just "swallowed" my function call but never executed it because the js-file I specified was never loaded.

Vivek PatilPosted May 2, 2018, 9:19 AM
Hi Sagar, Thank you for the solution. It is working for me. I used some other code for modal dialog in one of site collection and there it is working fine without any reference file. But same code is not working in other site collection. It is throwing error. Do you have any idea on it? If I add ref file then it will work but page layout get change and some strange things will be happen.