Chủ Nhật, 5 tháng 6, 2011

Tiện ích tự động Refresh cho Blogspot


(Traidatmui.com) - Nếu bạn muốn blog của bạn tự động "Reload" lại thì bài viết này sẽ rất có ích cho bạn. Đây là code sẽ giúp blog bạn tự động Refresh lại trong một khoảng thời gian nhất định mà bạn có thể cài đặt trước, đơn vị sẽ tính bằng giây. Tiện ích này sẽ có thêm phần đếm thời gian theo phương thức lùi "count down time", tức nếu bạn đặt là 60 giây thì nó sẽ đếm từ 60, 59, 58...1 và sau đó nó sẽ tự động Refresh blog.

» Bắt đầu thủ thuật

1. Đăng nhập tài khoản Blogger
2. Vào phần thiết kế (hay bố cục)
3. Chọn thêm tiện ích (Add a Gadget)
4. Thêm 1 HTML/Javascript và chèn vào nó code bên dưới
<script language="JavaScript">
var countDownInterval=30//thời gian refresh page
//configure width of displayed text, in px (applicable only in NS4)
var c_reloadwidth=200
</script>
<ilayer id="c_reload" width=&{c_reloadwidth}; ><layer id="c_reload2" width=&{c_reloadwidth}; left=0 top=0></layer></ilayer>

<script>

var countDownTime=countDownInterval+1;
function countDown(){
countDownTime--;
if (countDownTime <=0){
countDownTime=countDownInterval;
clearTimeout(counter)
window.location.reload()
return
}
if (document.all) //if IE 4+
document.all.countDownText.innerText = countDownTime+" ";
else if (document.getElementById) //else if NS6+
document.getElementById("countDownText").innerHTML=countDownTime+" "
else if (document.layers){
document.c_reload.document.c_reload2.document.write('Website sẽ tự động <a href="javascript:window.location.reload()">refresh</a> trong <b id="countDownText">'+countDownTime+' </b> giây')
document.c_reload.document.c_reload2.document.close()
}
counter=setTimeout("countDown()", 1000);
}

function startit(){
if (document.all||document.getElementById)
document.write('Website sẽ tự động <a href="javascript:window.location.reload()">refresh</a> trong <b id="countDownText">'+countDownTime+' </b> giây')
countDown()
}
if (document.all||document.getElementById)
startit()
else
window.onload=startit

</script>

5. Save tiện ích lại

Chúc bạn thành công


Địa chỉ bài viết: http://www.traidatmui.com/2011/04/tien-ich-tu-ong-refresh-cho-blogspot.html#ixzz1OT40IN4V
Nguồn: TRAIDATMUI.com

Không có nhận xét nào:

Đăng nhận xét