Cross Domain - Closing Window

7 posts, 0 answers
  1. SomeName
    SomeName avatar
    19 posts
    Member since:
    Jul 2011

    Posted 11 Jul 2011 Link to this post

    I'd like to close the opend window i called in a cross domain site.
    So, when the user hits the "Close" button on the child page (different domain) the radwindow shall close.

    This is easily possible with normal popup windows, just use the javascript code. window.close();
    In Demos you can find an example for Dialog returning values and there is a javascript method to find the radwindow and than call the close event, but this doesnt work in cross domain scenarios.

    Example from Demos
    function GetRadWindow() {
     
    var oWindow = null;
     if (window.radWindow)
    oWindow = window.radWindow;
     
    //Throws an Error in cross domain, because window.frameElement isnt accessible
    else if (window.frameElement.radWindow)
    oWindow = window.frameElement.radWindow;
     
    return oWindow;
     
     }


    To Close just say...
    var oWnd = GetRadWindow();
    oWnd.close(oArg);


    Hope you guys can help me close a radwindow in cross domain scenario.
  2. SomeName
    SomeName avatar
    19 posts
    Member since:
    Jul 2011

    Posted 19 Jul 2011 Link to this post

    Does anyone have an idea how to solve this problem?
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Marin Bratanov
    Admin
    Marin Bratanov avatar
    3597 posts

    Posted 20 Jul 2011 Link to this post

    Hello,

    Please note one main difference between a browser window and a RadWindow - the RadWIndow is actually a server control (i.e. a collection of HTML elements, JavaScript and CSS) that resides in the page. It cannot exist outside of the page lifecycle, while the browser is a standalone application in the user's machine.

    This means that you can interact with the RadWindow only via JavaSctipt in the context of its own page and JavaScript does not allow access from a different domain. Please examine the following google search for more information on this limitation: http://www.google.com/search?&q=javascript+crossdomain+policy.

    In conclusion - you can manipulate the RadWindow object only if you have access to the page that contains it. If you can do it from a different domain then oWnd.close() should work for you, but this would be hacking the other person's page and I doubt that it can be achieved.


    All the best,
    Marin
    the Telerik team

    Register for the Q2 2011 What's New Webinar Week. Mark your calendar for the week starting July 18th and book your seat for a walk through of all the exciting stuff we will ship with the new release!

  5. SomeName
    SomeName avatar
    19 posts
    Member since:
    Jul 2011

    Posted 20 Jul 2011 Link to this post

    Thanks for the answer. FYI, both domains are mine.
    I just need a to call a radwinow and there an aspx page, because of limitations that arent in my hand, i cannot run code on one server because it only works on the local machine.

    So what i have done is, from my webserver (1st domain) i call one single page on 2nd domain and do somestuff in the aspx page (that as metioned only works on local machine).
    When hitting the "Done/Close" Button i want to automatically close the RadWindow.

    Since you said first its not possible, but then mentioned about hacking it can be achieved.. I am not sure now, what the case is...

    So if its possible since both domains belong to me please tell me how to achieve it. Thanks in advance.
  6. Marin Bratanov
    Admin
    Marin Bratanov avatar
    3597 posts

    Posted 21 Jul 2011 Link to this post

    Hello again,

    Please excuse me for not being clear enough in my previous post. It does not matter who owns the domains, JavaScript will not allow you to access pages from different domains regardless of their physical owner. What I meant under hacking is exactly this - probably somewhere a hack/hacker exists that is capable of accessing another domain, but I cannot be certain of this. As far as we know there is no way to access a different domain via JavaScript, thus you couldn't close the RadWIndow from within if the page comes from another domain. The closest thing to a hack there is is changing the domain of the document object so that it uses only the last part of the domain, for example site1.mydomain.com and site2.mydomain.com could be made to look like mydomain.com and could be accessible under certain conditions. For more information on this approach please examine the following google search: http://www.google.com/search?q=cross+domain+javascript.


    Greetings,
    Marin
    the Telerik team

    Register for the Q2 2011 What's New Webinar Week. Mark your calendar for the week starting July 18th and book your seat for a walk through of all the exciting stuff we will ship with the new release!

  7. Greg
    Greg avatar
    13 posts
    Member since:
    Sep 2005

    Posted 14 Mar 2012 Link to this post

    I understand the restriction for cross domain close, but how is it your X (close) button works on the Radwindow itself?  Is there anyway to emulate the functionality of the X button like a regular button on the page?
  8. Kevin
    Kevin avatar
    360 posts
    Member since:
    Jul 2012

    Posted 15 Mar 2012 Link to this post

    Hello Greg,

    The reason you can close a RadWindow manually using the X (close) button is because that button is not conatined inside the iFrame of the RadWindow, which is referencing the external site, thus the X (close) button can access the RadWindow object. When an external page is displayed in the RadWindow and is not within the same domain as the page containing the RadWindow, the GetRadWindow() method cannot gain access the parent page that the iFrame is contained in because of security concerns and thus the reason it cannot access the RadWindow object and call the close method.

    I hope that makes sense.
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017