If I remember correctly, window.location.reload()
reloads the current page with POST data, while window.location.href=window.location.href
does not include the POST data.
(如果我没记错的话, window.location.reload()
用POST数据重新加载当前页面,而window.location.href=window.location.href
不包含POST数据。)
As noted by @W3Max in the comments below, window.location.href=window.location.href
will not reload the page if there's an anchor (#) in the URL - You must use window.location.reload()
in this case.
(如@ W3Max在下面的注释中所指出的,如果URL中有锚点(#),则window.location.href=window.location.href
将不会重新加载页面-在这种情况下,您必须使用window.location.reload()
。)
Also, as noted by @Mic below, window.location.reload()
takes an additional argument skipCache
so that with using window.location.reload(true)
the browser will skip the cache and reload the page from the server.
(另外,如下面的@Mic所述, window.location.reload()
带有附加参数skipCache
以便浏览器使用window.location.reload(true)
将跳过缓存并从服务器重新加载页面。)
window.location.reload(false)
will do the opposite, and load the page from cache if possible.(window.location.reload(false)
将执行相反的操作,并在可能的情况下从缓存加载页面。)
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…