Loads a resource into either a new browsing context (such as a window) or one that already exists, depending on the specified parameters.
示例
window.open()和window.opener
var winName = "MyWindow";
var wor = null; // windowObjectReference
function btnBaiDu(){
wor = window.open("http://www.baidu.com",winName);
}
function btnSina(){
wor = window.open("http://www.sina.com",winName);
}
function btnClose(){
wor.close();
}
演示图
Window.opener
https://developer.mozilla.org/en-US/docs/Web/API/Window/opener
Returns a reference to the window that opened this current window.
示例
window_opener.html
window.opener
alert("页面加载!");
function btnNewWindow(){
window.open("testWindow.html","test");
}
testWindow.html
测试窗口
function btnClose(){
window.opener.location.reload(true);
window.close();
}
演示效果图
地址:https://developer.mozilla.org/en-US/docs/Web/API/Location/reload Location.reload()
The Location.reload() method reloads the resource from the current URL. Its optional unique parameter is a Boolean, which, when it is true, causes the page to always be reloaded from the server. If it is false or not specified, the browser may reload the page from its cache.