简体   繁体   中英

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.

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);
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM