Sunday, 10 March 2013

Script to Open SharePoint Page in Dialogue Box in SharePoint 2010

<div>
<a href="javascript:OpenDialog(‘../SitePages/NewPage.aspx’);">Open Page In Dialogue Box</a>
 </div>


<style type="text/css">
.MyLinkDialog {
    MIN-HEIGHT: 100px; HEIGHT: auto !important
}
IMG.ms-newgif {
    DISPLAY: none
}
</style>


<script type="text/javascript">
//Dialog opening
function OpenDialog(url) {
var options = SP.UI.$create_DialogOptions();
options.url = url;
options.width = 450;
options.style="MyLinkDialog";
options.allowMaximize = false;
options.dialogReturnValueCallback = Function.createDelegate(null, CloseCallback);
SP.UI.ModalDialog.showModalDialog(options);
}
var messageId;
// Dialog callback
function CloseCallback(result, target) {
if (result == SP.UI.DialogResult.OK) {
//Get id
messageId = SP.UI.Notify.addNotification("<img src='_layouts/images/loading.gif'> Creating list <b>" + target + "</b>...", true, "Dialog response", null);
//Create list using client OM
//createList(target);
}
if (result == SP.UI.DialogResult.cancel) {
SP.UI.Notify.addNotification("Operation was cancelled...", false, "", null);
}
}
</script>

No comments:

Post a Comment