0

I am trying to open a modal pop up using the following JavaScript:

if (this.Context != null && !this.Context.Items.Contains(SPRequestModule.AllowFramingFlag)) {
    this.Context.Items.Add(SPRequestModule.AllowFramingFlag, "1");
}

var options = { url: "https://eeeee/Lists/ProjectLibrary/NewForm.aspx", width: 400, height: 300 };
//enter code here
SP.SOD.execute('sp.ui.dialog.js', 'SP.UI.ModalDialog.showModalDialog', options);`

I also added the site to the trusted sites zone. I get the following error

the content cannot be displayed in a frame sharepoint.

I also tried to open a iframe using

window.top.location.href = "https://eeeee/Lists/ProjectLibrary/NewForm.aspx" 

Still get the same result..

1 Answer 1

1

use the below script in CEWP:

<a onclick="modalcall()" href="#">New Request</a>
<script type="text/javascript">function modalcall() { 
    SP.UI.ModalDialog.showModalDialog({ 
    url: "NewForm.aspx", 
    title: "New Form", 
    allowMaximize: true, 
    showClose: true, 
    dialogReturnValueCallback: refreshCallback
    }); 
}; 
function refreshCallback(dialogResult, returnValue) { 
SP.UI.ModalDialog.RefreshPage(SP.UI.DialogResult.OK);}</script>

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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