這可能是一個很noob問題......但我無法弄清楚。刷新動畫,然後重定向到不同的網址
我有一個網頁,其中有一個按鈕..
我要的是..當我點擊該按鈕,則顯示「處理」
這樣
再經過幾秒鐘..期待一個url
說google.com
我相信這是非常平凡的..但我無法考慮它。
到目前爲止,我有什麼只是一個按鈕:(
這可能是一個很noob問題......但我無法弄清楚。刷新動畫,然後重定向到不同的網址
我有一個網頁,其中有一個按鈕..
我要的是..當我點擊該按鈕,則顯示「處理」
這樣
再經過幾秒鐘..期待一個url
說google.com
我相信這是非常平凡的..但我無法考慮它。
到目前爲止,我有什麼只是一個按鈕:(
使用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);
});
嘗試在.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);
});
嗨,你好,對不起,問大概一個非常愚蠢的問題,但如何將我的加載GIF與 「imgid」 關聯.. – Fraz 2013-03-07 06:32:26
只需調用一個img標籤來顯示你想要的地方的加載gif ...先隱藏它...然後顯示點擊.. :) ..應該做的伎倆..更新檢查..希望幫助.. – bipen 2013-03-07 06:34:07