【发布时间】:2010-04-10 10:35:54
【问题描述】:
我通过写window.location = window.location; 刷新页面。但是,这在 /page#c22 之类的页面上不起作用。它只会跳转到 c22 所在的位置。如何刷新页面?
刷新后不需要使用 go to #c22 但我相信有比window.location = window.location 更可靠的方法。
【问题讨论】:
标签: javascript html
我通过写window.location = window.location; 刷新页面。但是,这在 /page#c22 之类的页面上不起作用。它只会跳转到 c22 所在的位置。如何刷新页面?
刷新后不需要使用 go to #c22 但我相信有比window.location = window.location 更可靠的方法。
【问题讨论】:
标签: javascript html
你不妨试试:
window.location.reload(true);
reload(forceget):从当前 URL 重新加载文档。forceget是一个布尔值,当它是true时,会导致页面总是从服务器重新加载。如果它是false或未指定,浏览器可能会从其缓存中重新加载页面。 (Source)
【讨论】:
你可以用这个:
window.location.reload();
The spec for this is here, at the W3C
此函数强制宿主应用程序重新加载由 Location 标识的资源。
【讨论】:
试试:
location.reload(true)
【讨论】:
"Page auto reload with parameters" 是一种试图保留获取参数的方法。
您可能想使用location.pathname。
【讨论】: