我想知道如何刷新/重新加载页面(甚至是特定的div)一次(!)使用jQuery?
Ideally in a way right after the DOM structure
is available (cf. onload
event) and not negatively affecting back button
or bookmark
functionality.
请注意:由于第三方的限制,replace()
是不允许的.
我想知道如何刷新/重新加载页面(甚至是特定的div)一次(!)使用jQuery?
Ideally in a way right after the DOM structure
is available (cf. onload
event) and not negatively affecting back button
or bookmark
functionality.
请注意:由于第三方的限制,replace()
是不允许的.
Alright, I think I got what you're asking for. Try this
if(window.top==window) {
// You're not in a frame, so you reload the site.
window.setTimeout('location.reload()', 3000); //Reloads after three seconds
}
else {
//You're inside a frame, so you stop reloading.
}
如果只有一次,那就这么做吧
$('#div-id').triggerevent(function(){
$('#div-id').html(newContent);
});
如果是周期性的
function updateDiv(){
//Get new content through Ajax
...
$('#div-id').html(newContent);
}
setInterval(updateDiv, 5000); // That's five seconds
So, every five seconds the div #div-id content will refresh. Better than refreshing the whole page.