zondag 11 maart 2012

How to open a custom page in Modal Sharepoint Popup Window.


Last week we wanted to open a custom made sharepoint page 
in a Modal Sharepoint Popup window. 
But this without enabling the option to open all windows in a modal popup. 

This is easy to do. 
Here is a JavaScript that will allow you to open any page in the modal popupwindow of Sharepoint. 
 

//Handle the DialogCallback callback
function DialogCallback(dialogResult, returnValue){
    window.location = window.location;
}

//Open the Dialog
function OpenEditDialog(link){
    var options = {
        url:URL_TO_YOUR_PAGE + '&IsDlg=1',
        width: 700,
        height: 700,
        dialogReturnValueCallback: DialogCallback};
    SP.UI.ModalDialog.showModalDialog(options);
}
 

Notice that the IsDlg=1 query string parameter is appended 
within the OpenEditDialog function. 
The presence of “IsDlg” dynamically loads the "/_layouts/styles/dlgframe.css” file 
which applies “display:none” to all items using the “s4-notdlg” css class. 
This effectively hides items of this class in a dialog box. 
For example, v4.master uses the “s4-notdlg” class for the Ribbon control 
to hide the ribbon within dialogs.

 

Geen opmerkingen:

Een reactie posten