ak1111
ak1111

Reputation: 107

access value returned value of child window in parent window's function

I am opening a popup window to make oAuth now i want to catch the final output of the child window to the function from where its been populated.

    $scope.login__linkedin=function() {

            var child_window=$window.open('http://localhost/oAuthTest/lrvl/public/login','Authentication', 'width=500,height=500');

            child_window.onload = function() {
                setTimeout(function(){ console.log(child_window.document.documentElement.outerHTML) }, 2000);
//i want my child window value somewhere here.
             }  

            };

i am not getting my final success response code (i am getting nothing actually) in console. I want to make login via linkedin and success in opening the window and getting the user authenticated,but the success response if showing me on my child window i want to get this response on my parent window.

Upvotes: 1

Views: 687

Answers (2)

stas.yaranov
stas.yaranov

Reputation: 1787

Try to replace $window with window

What the following gives?

(function() {
    var child_window=window.open('http://localhost/oAuthTest/lrvl/public/login','Authentication', 'width=500,height=500');
    child_window.onload = function() {
                setTimeout(function(){ alert(child_window.document.documentElement.outerHTML); }, 2000);
    }
})();

Upvotes: 1

Charlie
Charlie

Reputation: 23838

Open your child window

 var child_window=$window.open('http://localhost/oAuthTest/lrvl/public/login','Authentication', 'width=500,height=500');

(I'm sure this is from the same domain)

Add a function for the popup window to execute. This function can transfer some data from Popup to Caller through arguments.

child_window.selectUser = function(userId) {
     console.log(userId);

     //Do whatever you like with this authenticated user
}

Now your popup window has selectUser function which it can call after authenticating the user.

Upvotes: 1

Related Questions