META name="y_key" content="24902eb207816366"> tuduytuonglai: Tạo các dòng thông báo kiểu gõ văn bản

24 tháng 7, 2010

Tạo các dòng thông báo kiểu gõ văn bản

[FD's BlOg] - Thông thường khi không muốn cho 1 đoạn văn bản nào đó chỉ hiển thị trên 1 dòng hoặc 1 khu vực nhỏ nào đó, ta thường dùng hiệu ứng chạy chữ để hiển thị nó. Với việc này các đoạn văn bản đó sẽ không chiếm nhiều không gian trong blog của bạn. Hôm nay mình sẽ giới thiệu 1 kiểu hiển thị khác, đó là kiểu hiển thị tương tự khi ta đánh 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.

0 nhận xét:

Đăng nhận xét


♦ Mời bạn gửi Nhận xét của mình. Nếu không có tài khoản Blogger-Google, LiveJournal, WordPress, TypePad, AIM, OpenID, bạn vẫn có thể nhận xét bằng cách chọnComment asTên/URL hay Ẩn danh. Tuy nhiên bạn nên chọn Tên/URL với URL có thể để trống. Bạn vui lòng gõ tiếng Việt có dấu.

♦ Bấm vào Xem trước [Preview] bên dưới khung nhận xét nếu muốn xem trước comment đã viết, trước khi post [đăng]. Tương tự, bấm vào Đăng ký qua email [Subscribe by email] để đăng ký theo dõi nhận xét của bài này.

♦ Các bạn tự chịu trách nhiệm với Nhận xét của mình. Nhận xét để phản hồi, đánh giá, góp ý.... suy nghĩ của bạn. Thông qua Nhận xét hãy để cho mọi người biết Bạn là ai.
Xem ký tự của emoticons khỉ Yoyo tại đây.

^ Scroll to Top