akshay
akshay

Reputation: 21

is it possible to close child window from parent window?

i am with stuck an unorthodox requirement, i have opened a window on page load using jquery like this

 $(document).ready(function() {

 loadLifeCare();

        });

and the function goes like this

function loadLifeCare()
    {
        window.open('/abc/abc/abc','','width=100,height=100');
    }

now this function loads a url in the new window which creates a session for the user on different domain. i just need to know if it is either possible to close this window after few seconds or change the href and reload it to a different link, and i can't code on the child window.

Upvotes: 1

Views: 316

Answers (1)

Reinstate Monica Cellio
Reinstate Monica Cellio

Reputation: 26143

This will open the window and then close it after 10 seconds...

function loadLifeCare()
{
    var wnd = window.open('/abc/abc/abc','','width=100,height=100');
    setTimeout(function() {
        wnd.close();
    }, 10000);
}

If you want to redirect it elsewhere, you can do this...

function loadLifeCare()
{
    var wnd = window.open('/abc/abc/abc','','width=100,height=100');
    setTimeout(function() {
        wnd.location.href = "http://wherever.com";
    }, 10000);
}

Upvotes: 3

Related Questions