I have a button on the main page, which will open (window.open()) a window W1 to allow user to select stuff on it. After that, user press OK button on the W1 to open window W2 (again window.open()). How can i close the W1 after the user press OK?
I have a button on the main page, which will open (window.open()) a window W1 to allow user to select stuff on it. After that, user press OK button on the W1 to open window W2 (again window.open()). How can i close the W1 after the user press OK?
Share Improve this question asked Feb 7, 2012 at 2:33 Thai TranThai Tran 9,9357 gold badges47 silver badges66 bronze badges 02 Answers
Reset to default 3Use the window.close()
method with the name of the target window as shown below:
win1 = window.open("","","width=100,height=100");
okBtn.onclick = function() {
win2 = window.open("","","width=100,height=100");
win1.close();
}
On the main page you save popup into W1 and define a function that will close W1:
W1 = window.open("","","width=100,height=100");
function closeW1() {
W1.close();
}
Now on W1 in the same place where you open W2:
okBtn.onclick = function() {
W2 = window.open("","","width=100,height=100");
window.opener.closeW1();
}
That's it. You're done.
发布者:admin,转转请注明出处:http://www.yc00.com/questions/1744355324a4570203.html
评论列表(0条)