esac
esac

Reputation: 24685

How to get the title of a window opened by a popup?

I am opening a popup of another site (google oauth2). The site I load will display information in the title bar, so I want to monitor the title bar to extract the information. Whenever I do this, however, the title is always blank even though the window does have a title. Here is what I am trying right now just for testing.

var authWindow = null;

function popup(url) {
    authWindow = window.open(url, 'Authentication', 'height=600,width=450');

    if (window.focus) {
        authWindow.focus();
    }

    $(authWindow.document).ready(monitorForAuthCode);
}

function monitorForAuthCode()
{
    if (authWindow && authWindow.closed == false)
    {
        var code = authWindow.document.title;

        $('#hash').html($('#hash').html() + code + '<br>');

        setTimeout(monitorForAuthCode, 1000);

    }
}

Upvotes: 2

Views: 1757

Answers (1)

epascarello
epascarello

Reputation: 207527

popup of another site (google oauth2)

You can not read the contents of another domain because of the same origin policy.

Upvotes: 2

Related Questions