I am trying to create a modal that generates off of a link. When the link is clicked, the modal pops-up but I get the error, "An unexpected error has occurred". When I dive deeper, I find out that SharePoint has appended '?IsDlg=1' to the URL, which causes it to error out. How can I fix this issue? Code below:
<script type="text/javascript">
//User Defined Function to Open Dialog Framework
function OpenDialog(strPageURL)
{
var dialogOptions = SP.UI.$create_DialogOptions();
alert(dialogOptions);
dialogOptions.url = strPageURL;// URL of the Page
dialogOptions.title = 'Welcome to SharePoint'
dialogOptions.allowMaximize= true
dialogOptions.width = 950; // Width of the Dialog
dialogOptions.height = 500; // Height of the Dialog
dialogOptions.dialogReturnValueCallback = Function.createDelegate( null,
CloseCallback); // Function to capture dialog closed event
SP.UI.ModalDialog.showModalDialog(dialogOptions); // Open the Dialog
return false;
}
function CloseCallback(strReturnValue, target)
{
if (strReturnValue === SP.UI.DialogResult.OK) // Perform action on Ok.
{
alert("User clicked Ok!");
}
if (strReturnValue === SP.UI.DialogResult.cancel) // Perform action on
Cancel.
{
alert( "User clicked Cancel!");
}
}
</script>
</head>
<body>
<a onclick="OpenDialog('../SitePages/vueCarausel.aspx');">open dialog</a>
</body>