gia*_*bao 848
JavaScript 1.0
window.location.href = window.location.pathname + window.location.search + window.location.hash;
// creates a history entry
Run Code Online (Sandbox Code Playgroud)
JavaScript 1.1
window.location.replace(window.location.pathname + window.location.search + window.location.hash);
// does not create a history entry
Run Code Online (Sandbox Code Playgroud)
JavaScript 1.2
window.location.reload(false);
// If we needed to pull the document from
// the web-server again (such as where the document contents
// change dynamically) we would pass the argument as 'true'.
Run Code Online (Sandbox Code Playgroud)
Lek*_*eyn 313
location.reload();
Run Code Online (Sandbox Code Playgroud)
有关更多信息,请参阅此MDN页面.
Jer*_*lle 185
以下是使用JavaScript重新加载页面的535种方法,最简单的方法location = location.
这是第50个:
location = location
location = location.href
location = window.location
location = self.location
location = window.location.href
location = self.location.href
location = location['href']
location = window['location']
location = window['location'].href
location = window['location']['href']
location = window.location['href']
location = self['location']
location = self['location'].href
location = self['location']['href']
location = self.location['href']
location.assign(location)
location.replace(location)
window.location.assign(location)
window.location.replace(location)
self.location.assign(location)
self.location.replace(location)
location['assign'](location)
location['replace'](location)
window.location['assign'](location)
window.location['replace'](location)
window['location'].assign(location)
window['location'].replace(location)
window['location']['assign'](location)
window['location']['replace'](location)
self.location['assign'](location)
self.location['replace'](location)
self['location'].assign(location)
self['location'].replace(location)
self['location']['assign'](location)
self['location']['replace'](location)
location.href = location
location.href = location.href
location.href = window.location
location.href = self.location
location.href = window.location.href
location.href = self.location.href
location.href = location['href']
location.href = window['location']
location.href = window['location'].href
location.href = window['location']['href']
location.href = window.location['href']
location.href = self['location']
location.href = self['location'].href
location.href = self['location']['href']
location.href = self.location['href']
...
Run Code Online (Sandbox Code Playgroud)
Nik*_*wal 78
您可以使用执行此任务window.location.reload();.由于有很多方法可以做到这一点,但我认为这是用JavaScript重新加载同一文档的适当方法.这是解释
window.location可以使用JavaScript 对象
window:在JavaScript中表示浏览器中的打开窗口.
location:在JavaScript中保存有关当前URL的信息.
该location对象就像是对象的一个片段,window并通过window.location属性调用.
location 对象有三种方法:
assign():用于加载新文档reload():用于重新加载当前文档replace():用于替换当前文档的新文档所以这里我们需要使用reload(),因为它可以帮助我们重新加载相同的文档.
所以就像使用它一样window.location.reload();.
要让浏览器直接从服务器检索页面而不是从缓存中检索页面,可以将true参数传递给location.reload().此方法与所有主流浏览器兼容,包括IE,Chrome,Firefox,Safari,Opera.
Ora*_*ane 42
尝试:
window.location.reload(true);
Run Code Online (Sandbox Code Playgroud)
设置为"true"的参数会从服务器重新加载新副本.离开它将从缓存服务页面.
可以在MSDN和Mozilla文档中找到更多信息.
Sta*_*wii 40
我正在寻找有关使用POST请求检索的页面上的重新加载的一些信息,例如在提交method="post"表单之后.
要重新加载保留POST数据的页面,请使用:
window.location.reload();
要重新加载丢弃POST数据的页面(执行GET请求),请使用:
window.location.href = window.location.href;
希望这可以帮助其他人寻找相同的信息.
ume*_*mer 35
这对我有用:
function refresh() {
setTimeout(function () {
location.reload()
}, 100);
}
Run Code Online (Sandbox Code Playgroud)
http://jsfiddle.net/umerqureshi/znruyzop/
小智 15
如果你放
window.location.reload(true);
Run Code Online (Sandbox Code Playgroud)
在页面的开头没有其他条件限定为什么代码运行,页面将加载,然后继续重新加载自己,直到您关闭浏览器.
gui*_* 桂林 11
location.href = location.href;
Run Code Online (Sandbox Code Playgroud)
使用按钮或只是将其放在"a"(锚)标签内:
<input type="button" value="RELOAD" onclick="location.reload();" />
Run Code Online (Sandbox Code Playgroud)
尝试这些以满足其他需求:
Location Objects has three methods --
assign() Used to load a new document
reload() Used to reloads the current document.
replace() Used to replace the current document with a new one
Run Code Online (Sandbox Code Playgroud)
小智 5
这应该有效:
window.location.href = window.location.href.split( '#' )[0];
Run Code Online (Sandbox Code Playgroud)
或者
var x = window.location.href;
x = x.split( '#' );
window.location.href = x[0];
Run Code Online (Sandbox Code Playgroud)
我更喜欢这个,原因如下:
或者,您可以使用最新的官方方法来完成此任务
window.location.reload()
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
908953 次 |
| 最近记录: |