Friday, February 1, 2013

Modal Popup in Sharepoint by javascript

Most come requirement in Sharepoint custom developemt is to have a popup .This can be achieved by using the Modal PopUp .Below is the code script which gives us popup in sharepoint


<script type=”text/javascript”>

function OpenDialog(URL) {
     var options = SP.UI.$create_DialogOptions();
     options.url = URL;
     options.width = 600;
     options.height = 400;
     SP.UI.ModalDialog.showModalDialog(options);
}

</script>

<a href=”javascript:OpenDialog(‘URL of the page to be displayed here’)”>Link</a>


You can use this script in a .js file reference it anywhere in the sharepoint site and you should be able to call the function .

3 comments:

  1. Would this work with a Script Editor web part or does it need to be in a .js file? I tried using it in a web part but it didn't do anything, maybe I'm missing something?

    ReplyDelete
    Replies
    1. yes it will work in the script editor webpart too.

      Delete