Code Snippet:
I have created a page and added the Script Editor Web Part.
- <script type="text/javascript">
-
-
- function OpenDialog(strPageURL) {
- var dialogOptions = SP.UI.$create_DialogOptions();
- dialogOptions.url = strPageURL;
-
- dialogOptions.width = 800;
-
- dialogOptions.height = 630;
-
-
- dialogOptions.dialogReturnValueCallback = Function.createDelegate(null, CloseCallback);
-
- SP.UI.ModalDialog.showModalDialog(dialogOptions);
- return false;
- }
-
-
- function CloseCallback(strReturnValue, target) {
- if (strReturnValue === SP.UI.DialogResult.OK) {
-
- }
- if (strReturnValue === SP.UI.DialogResult.cancel) {
-
- }
- }</script>
- <div><a onclick="return OpenDialog("https:
- href="https://c986.sharepoint.com/SitePages/Test.aspx">
- Click here to show Modal Dialog</a></div>
Result:
Reference:
https://msdn.microsoft.com/en-us/library/office/ff410058(v=office.14).aspx.