Click - delay before navigating

前端 未结 1 409
旧巷少年郎
旧巷少年郎 2020-12-08 05:21

is there any easy way to create a code: if URL changes or clicked on a link show div (like loading gif 3-sec) then show the page? Kinda like blank white page with loading gi

相关标签:
1条回答
  • 2020-12-08 06:05
    $('a').click(function (e) {
        e.preventDefault();                   // prevent default anchor behavior
        var goTo = this.getAttribute("href"); // store anchor href
    
        // do something while timeOut ticks ... 
    
        setTimeout(function(){
             window.location = goTo;
        }, 3000);                             // time in ms
    }); 
    
    0 讨论(0)
提交回复
热议问题