1

I am working with SharePoint hosted apps, and I require to display the default SharePoint version history page of a list item in a modal dialog popup.
(url/_layouts/15/Versions.aspx?list={"+listId+"}&ID="+itemId). However I get "This page cannot be display" as in the screenshot.
This is the piece of code I used.

var hostweburl = decodeURIComponent(manageQueryStringParameter('SPHostUrl'));
var listId = 'F7C3D94A-9762-47C6-8A9C-024922982574';
var itemId = 100;
var versionURL = hostweburl + "/_layouts/15/Versions.aspx?list={" + listId + "}&ID=" + itemId;
ExecuteOrDelayUntilScriptLoaded(openVersionHistory, "SP.js");


    function openVersionHistory() {
        var options = {
            title: 'Version History',
            url: versionURL,
            width: 500,
            height: 500
        }

        SP.UI.ModalDialog.showModalDialog(options);
        return false;
    }

enter image description here

1

Modal Dialog is nothing but an iframe and this generally happens in SharePoint App development as the default value of X-FRAME-OPTIONS is set to Same Origin in every SharePoint request which means your SharePoint site will disallow loading of contents in an iframe from other domains.

For this you have to set <WebPartPages:AllowFraming runat="server" /> in your master page which will allow loading the contents from other origins also in Modal dialog which in your case will be from Host web.

For more information please visit this blog

A similar question was asked from which you can get more help.

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.