none
Open Dialog Window in Parent Frame RRS feed

  • Question

  • I have a page viewer web part on my page which is surfacing a News page from another part of our SharePoint farm.  This News page contains links to many articles which I have told to open in a Dialog window using the following code:

    function DisplayArticle(url)
    {
    var options = SP.UI.$create_DialogOptions();
    options.width = 900;
    options.height = 800;
    options.url = url;
    SP.UI.ModalDialog.showModalDialog(options);
    }

    This is working fine although the dialog opens within the boundary of the Page Viewer web part and I would like it to open as if it was a dialog of the parent window.

    Any thoughts?

    Wednesday, May 22, 2013 4:22 PM

Answers

  • Thanks for your reply.

    Unfortunately your suggestion didn't work although it did prompt me to try something I hadnt previously attempted.  Simply adding parent. before the SP.UI lines did the trick :)

    function DisplayArticle(url)
    {
    var options = parent.SP.UI.$create_DialogOptions();
    options.width = 900;
    options.height = 800;
    options.url = url;
    parent.SP.UI.ModalDialog.showModalDialog(options);
    }

    • Marked as answer by Emir Liu Thursday, May 30, 2013 2:57 AM
    Thursday, May 23, 2013 7:36 AM

All replies

  • Hi,

    Because the dialog function is running within the context of the iframe, seems like its creating the dialog divs as children of the iframe's.

    You can do something like this:

    1) Create some Javascript function in the parent page, some thing like this:

    	function DisplayArticleInParent(url)
    	{
    		var options = SP.UI.$create_DialogOptions();
    		options.width = 900;
    		options.height = 800;
    		options.url = url;
    		SP.UI.ModalDialog.showModalDialog(options);
    	}

    2) from inside the iframe call parent pages function which we created above something like this:

    parent.DisplayArticleInParent('your article url');

    Genrally window.parent returns a reference to the parent of the current window or subframe.When a window is loaded in an <iframe>, <object>, or <frame>, its parent is the window with the element embedding the window.

    Please refer following link for calling parent window function: http://forums.asp.net/t/1117770.aspx

    Hope It might help you



    Please don't forget to 'mark answer/propose answer' or 'vote as helpful' as appropriate.



    Thursday, May 23, 2013 2:27 AM
  • Thanks for your reply.

    Unfortunately your suggestion didn't work although it did prompt me to try something I hadnt previously attempted.  Simply adding parent. before the SP.UI lines did the trick :)

    function DisplayArticle(url)
    {
    var options = parent.SP.UI.$create_DialogOptions();
    options.width = 900;
    options.height = 800;
    options.url = url;
    parent.SP.UI.ModalDialog.showModalDialog(options);
    }

    • Marked as answer by Emir Liu Thursday, May 30, 2013 2:57 AM
    Thursday, May 23, 2013 7:36 AM
  • Hi Fester,

    I tried using the parent.SP.UI but it gives me Access Denied for parent.SP for my App Part

    Is there anything specific you did for the same?

    Thanks


    -Amar Trivedi


    • Edited by Amar Trivedi Wednesday, October 22, 2014 9:43 AM Signature
    Wednesday, October 22, 2014 9:42 AM
  • I have also used parent.SP.UI but is showing error Access Denied for Parent.SP because i have used Client Webpart in SharePoint Online . Can you help me how we can call parent.SP in SharePoint hosted app ?
    Monday, June 1, 2015 10:50 AM