Refresh (reload) a page once using jQuery?

前端 未结 14 1758
眼角桃花
眼角桃花 2020-11-30 22:34

I\'m wondering how to refresh/reload a page (or even specific div) once(!) using jQuery?

Ideally in a way right after the DOM structure is available (c

相关标签:
14条回答
  • 2020-11-30 22:42

    You don't have a jQuery refresh function, because this is JavaScript basics.

    Try this:

    <body onload="if (location.href.indexOf('reload')==-1) location.replace(location.href+'?reload');">
    
    0 讨论(0)
  • 2020-11-30 22:42

    Use this instead

    function timedRefresh(timeoutPeriod) {
        setTimeout("location.reload(true);",timeoutPeriod);
    }
    
    <a href="javascript:timedRefresh(2000)">image</a>
    
    0 讨论(0)
  • 2020-11-30 22:45
    window.location.href=window.location.href;
    
    0 讨论(0)
  • 2020-11-30 22:46

    You may need to use this reference along with location.reload() check this, it will work.

    this.location.reload();
    
    0 讨论(0)
  • 2020-11-30 22:49

    Try this code:

    $('#iframe').attr('src', $('#iframe').attr('src'));
    
    0 讨论(0)
  • 2020-11-30 22:54

    To reload, you can try this:

    window.location.reload(true);
    
    0 讨论(0)
提交回复
热议问题