Home » Thủ thuật blog
Tạo các dòng thông báo kiểu gõ văn bản

Xem demo ở đây: LIVE DEMO
Hình minh họa :

☼ Sau đây là code của thủ thuật:
- Để thực hiện, bạn chỉ tạo 1 widget HTML/Javascript và việc dán toàn bộ code bên dưới vào :
<script language="JavaScript1.2">
var ts_line=new Array()
var ts_link=new Array()
ts_line[1]="Chào mừng các bạn đến với BlOg thủ thuật - BlOg FD"
ts_line[2]="BlOg được thành lập với niềm đam mê của bản thân về thế giới mạng"
ts_line[3]="Với tinh thần giúp đỡ, cùng nhau phát triển cộng đồng Blogger ở Việt Nam"
ts_line[4]="BlOg FD sẵn sàng giúp đỡ các bạn trong việc thiết kế, chỉnh sửa blog"
ts_line[5]="Với hơn 200 thủ thuật cho blogspot, từ dễ đến khó"
ts_line[6]="Và những hướng dẫn rất cụ thể và chi tiết"
ts_line[7]="Hy vọng BlOg FD sẽ là địa điểm dừng chân cho các Blogger Việt"
ts_line[8]="WELCOME TO BlOg FD"
var ts_fontcolor="#FB6B01" // màu chữ
var ts_fontsize="10pt" //kích thước chữ
var ts_fontweight="normal" // độ đậm
var ts_fontfamily="Verdana" // font chữ
var ts_bgcolor="transparent" // màu nền
var ts_bordercolor="#cccccc" //màu của đường viền
var ts_bordersize="1px" //độ rộng của đường viền
var ts_borderstyle="solid" // style của đường viền
var ts_padding="5px" // căn lề
var ts_width="200px" // độ rộng của khung hiển thị
var ts_height="100px" // chiều cao của khung hiển thị
var ts_delay="3000" // thời gian giãn cách hiển thị các đoạn văn bản
var ts_speed="35" // tốc độ typing (tốc độ hiển thị các từ)
var ts_linespread="1.2"
var ts_rand=0
<!--
/*
Typing Scroller
Submitted by bengaliboy00@hotmail.com (hp: http://www.angelfire.com/nt/bengaliboy/)
With modifications by Dynamicdrive.com
For full source code, usage terms, and 100s more scripts, visit http://dynamicdrive.com
*/
//--Don't edit below this line
var longestmessage=1
for (i=2;i<ts_line.length;i++){
if (!ts_line[i] ) {ts_line[i] = ''; ts_link[i] = '#';}
if (ts_line[i].length>ts_line[longestmessage].length)
longestmessage=i
}
//Auto set scroller width
var tscroller_width=ts_line[longestmessage].length
lines=ts_line.length-1 //--Number of lines
counter123 = 0;
temp=""
nextchar=-1;
var shown = new Array();
for (i = 1; i <= lines; i++ ) {
shown[i] = 0;
}
function checkshown() {
var num = 0;
for (i = 1; i<= lines; i++){
if (shown[i]) num++;
}
if ((num > (lines - 2))||(lines < 2)) {
for (i = 1; i <= lines; i++ ) {
shown[i] = 0;
}
}
return;
}
if (ts_rand == 1) {
checkshown();
do{
nextline=Math.floor(Math.random() * (lines + 1)); //1;
} while (shown[nextline] != 0);
shown[nextline] = 1;
} else {
nextline = 1;
}
cursor="\\"
//if IE 4+ or NS6
if (document.all||document.getElementById){
document.write('<table style="width: '+ts_width+'; height: '+ts_height+';">')
document.write('<tr><td')
document.write(' style=" cursor:hand; background-color: '+ts_bgcolor+'; color: '+ts_fontcolor+'; font-family: '+ts_fontfamily+'; font-size: '+ts_fontsize+'; font-weight:'+ts_fontweight+'; border-color: '+ts_bordercolor+'; border-style: '+ts_borderstyle+'; border-width: '+ts_bordersize+'; padding: '+ts_padding+'; width: '+ts_width+'; height: '+ts_height+'; text-align:left; vertical-align:top; " onfocus="blur()" ')
document.write('<a onclick="document.location=this.href;" id="banner_xyz_scroller" ')
document.write(' style="line-height: '+ts_linespread+'; color: '+ts_fontcolor+'; font-family: '+ts_fontfamily+'; font-size: '+ts_fontsize+'; font-weight:'+ts_fontweight+'; " ')
document.write (' href="javascript: void(0);"></a>')
document.write('</td></tr></table>')
}
var scroller = document.getElementById("banner_xyz_scroller");
function animate(){
if (temp==ts_line[nextline] & temp.length==ts_line[nextline].length & nextline!=lines){
if (ts_link[nextline]) {
//scroller.href="index.php?option=com_content&task=view&id="+ ts_link[nextline];
scroller.href="http://luyenthianhvan.org";
}
if (ts_rand == 1) {
checkshown();
do {
nextline = Math.floor(Math.random() * (lines + 1)); //nextline++;
}while (shown[nextline] != 0);
shown[nextline] = 1;
} else {
nextline++;
}
nextchar=-1;
scroller.innerHTML=temp;
temp="";
setTimeout("nextstep()",ts_delay)}
else if (nextline==lines & temp==ts_line[nextline] & temp.length==ts_line[nextline].length){
if (ts_link[nextline]) {
//scroller.href="index.php&id="+ ts_link[nextline];
scroller.href="http://luyenthianhvan.org";
}
if (ts_rand == 1) {
checkshown();
do{
nextline= Math.floor(Math.random() * (lines + 1)); //1;
}while (shown[nextline] != 0);
shown[nextline] = 1;
} else {
nextline = 1;
}
nextchar=-1;
scroller.innerHTML=temp;
temp="";
setTimeout("nextstep()",ts_delay)}
else{
nextstep()}}
function nextstep(){
if (cursor=="\\"){
cursor="|"}
else if (cursor=="|"){
cursor="/"}
else if (cursor=="/"){
cursor="-"}
else if (cursor=="-"){
cursor="\\"
}
nextchar++;
temp+=ts_line[nextline].charAt(nextchar);
scroller.innerHTML=temp+cursor
setTimeout("animate()",ts_speed)}
//if IE 4+ or NS6
if (document.all||document.getElementById)
window.onload=animate
// -->
</script>
- ts_line[1], ts_line[2], ... là các đoạn văn bản sẽ hiển thị. Nếu bạn không muốn nó hiển thị nhiều lần thì gộp chung tất cả lại thành 1.
- Hãy dựa vào các code chú thích màu xanh để chỉnh sửa cho khung hiển thị. Có thể xóa các code chú thích màu xanh này đi khi thực hiện.
Nguồn : dynamicdrive.com
Chúc các bạn thành công.

- [ Yêu cầu ] Tạo bookmark Sharing is sexy !
- Hướng dẫn rút ngắn tiêu đề bài viết cho tiện ích Recent posts
- [ Yêu cầu ] : Tạo button "Gửi Bài Viết" cho các thành viên trong BlOg
- [ Yêu cầu ] : Chèn 1 box nhỏ hiển thị các bài liên quan vào ngay trên đầu bài viết
- [ Yêu cầu ] : Tạo mô tả cho link trong bài viết
- Giải pháp Blogger bị chặn 02/07/2012
- Các truy vấn cơ bản với Blogspot
- Nâng cấp ANC Gdata lên phiên bản 2.
- Hướng dẫn config domain cho hầu hết các mạng.
- Khắc phục hiện tượng chặn web của VNPT.
- Giải pháp VNPT chặn blogger ngày 09/06/2012
- Tạo thumb cho bài đăng phổ biến
Comments[ 0 ]
Đăng nhận xét