Tutorial: window.getGroup

window.getGroup

Returns the native JavaScript "window" object for the window. This method can only be used by the parent application or the window itself, otherwise it will return undefined. The same Single-Origin-Policy (SOP) rules apply for child windows created by window.open(url) in that the contents of the window object are only accessible if the URL has the same origin as the invoking window. See example below. Also, will not work with fin.desktop.Window objects created with fin.desktop.Window.wrap().

Example

var sameOrigin = window.location.origin,
    wnd1 = new fin.desktop.Window({
    url: sameOrigin + "/window.html",
    name: "wnd1"
}, function () {
    var nativeWnd1 = wnd1.getNativeWindow();
    // logs the document of the window with the same origin
    console.log(nativeWnd1.document);
});

var someOtherOrigin = "http://www.arandomserver.com",
    wnd2 = new fin.desktop.Window({
    url: someOtherOrigin + "/window.html",
    name: "wnd2"
}, function () {
    var nativeWnd2 = wnd2.getNativeWindow();
    // logs undefined due to different origin (contents not accesible)
    console.log(nativeWnd2.document);
});