[英]Refresh animation and then redirect to different url
這可能是一個非常無聊的問題......但我無法弄明白。
我有一個頁面,有一個按鈕..
我想要的是..當我點擊那個按鈕然后它顯示一個“處理”的動畫
像這樣
然后幾秒鍾后......轉發到網址
說google.com
我相信這是非常微不足道的......但我無法思考它。
到目前為止,我只有一個按鈕:(
試試.click()
並使用setTimeout()
:
$(function(){
$('button').click(function(){
$('body').addClass('processing'); // <---------css class with bg img of loading
setTimeout(function(){
window.location.href = 'http://google.com';
},2000); //<---------after 2 sec page redirect to specified location.
});
});
更好地使用這種方式:
$('button').click(function () {
$(this).after('<img src="http://www.ebay.vn/assets/96ab871/images/loading.gif" />');
setTimeout(function () {
window.location.href = 'http://jsfiddle.net/6nMKb/';
}, 2000);
});
使用setTimeout()
在兩秒后調用該位置.. window.loaction
進行重定向
嘗試這個
HTML
<button id="buttonId">click</button>
<img src="loading.gif" id="imgid" style="display:none"/>
jQuery的
$('#buttonId').click(function(){
$('#imgid').show(); //this is where you'll show your loading gif
setTimeout(function(){window.location="http://google.com";}, 2000);
});
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.