Skip to content

SharePoint JavaScript Dialog Handling

Detailed post: SharePoint: How to close a Modal Dialog Window

Some sample JavaScript code:

function showUserPolicyDialog() {
    var options = SP.UI.$create_DialogOptions();
    options.title = Res.userPolicyDialogTitle;
    options.autoSize = true;
    options.showClose = false;
    options.allowMaximize = true;
    options.url = SP.Utilities.Utility.getLayoutsPageUrl("UserPolicyRequestPage.aspx?isDlg");
    options.dialogReturnValueCallback = showUserPolicyDialogCallback;

    userPolicyDialog = SP.UI.ModalDialog.showModalDialog(options);

function showUserPolicyDialogCallback(returnValue, dialogResult) {
    switch (returnValue) {
        case SP.UI.DialogResult.OK:
            // redirect to the start page of the intranet
            window.location = "http://intranet";

function userPolicyClick(accepted) {
    if (accepted) {
        window.frameElement.commonModalDialogClose(1, 'Closed with OK result');
    } else {
        window.frameElement.commonModalDialogClose(0, 'Closed with Cancel result');

Leave a Reply

Your email address will not be published. Required fields are marked *

By transmitting your comment you agree to our mentioned privacy policy content.

two × five =