ExecuteOrDelayUntilScriptLoaded(yourFunction, 'sp.js');

        function yourFunction() 

      var options = { url: 'https://mywebsite.sharepoint.com/MyApp/Pages/Default.aspx', title: 'Policy', width: 900, height: 400,dialogReturnValueCallback: onPopUpCloseCallBack };


         function onPopUpCloseCallBack(result, returnValue) 
             if(result== SP.UI.DialogResult.OK)

                  var sId = SP.UI.Status.addStatus("you clicked ok");
                  SP.UI.Status.setStatusPriColor(sId, 'green');
            else if(result== SP.UI.DialogResult.cancel)
                 var sId = SP.UI.Status.addStatus("you clicked cancel");
                 SP.UI.Status.setStatusPriColor(sId, 'yellow');

I have used the above code to display a page named Default.aspx in a modal popup but unfortunately it gives me following error

enter image description here

Am I doing something wrong Or its not possible to display a page in modal popup in SharePoint Online?

The same code works perfectly on SharePoint 2013 on premise.

Can anyone help?



Use below script in CEWP

<a onclick="modalcall()" href="#">New Request</a>
<script type="text/javascript">function modalcall() { 
    url: "NewForm.aspx", 
    title: "New Form", 
    allowMaximize: true, 
    showClose: true, 
    dialogReturnValueCallback: refreshCallback
function refreshCallback(dialogResult, returnValue) { 

the content cannot be displayed in a frame sharepoint


You have two options, use a html page if it's possible, or add <WebPartPages:AllowFraming ID="AllowFraming" runat="server" /> to your aspx page.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.