May 30, 2021 Article blog
window.open()
in javascript and
window.location.href
1, window.open ('index.html') means that a new window opens the index .html this page and does not refresh
Location.href ('index.html') means redirecting to a new page in the current window, opening and refreshing the index .html page
2, window.location is the property of the window object, used to replace the current page, that is, to relocate the current page
Window.open, on the other hand, is the method of the window object, a function used to open a new window
// 打开新页面
// 注意:有些浏览器的安全设置会将window.open()屏蔽,例如避免弹出广告窗
window.open('./index.html');
// 在原窗口打开新页面
window.location.href="./index.html";
window.open ('page.html', 'newwindow', 'height=100, width=400, top=0, left=0, toolbar=no, menubar=no, scrollbars=no, resizable=no,location=n o, status=no')
Parameter interpretation: Three parameters
Here's an example with the a label
<a href="javascript: history.back(-1)">返回上一页</a>
<a href="javascript:history.go(-1)">返回上一页</a>
<a href="javascript:history.go(-2)">返回前两页</a>
<a href="javascript:location.reload()">刷新当前页面</a>
<a href="javascript:" onclick="self.location=document.referrer;">返回上一页并刷新</a>
JavaScript
// 刷新当前页面
window.location.Reload();
self.location.reload();
window.location.href = window.location.href;