Bạn có thể nói rõ hơn được không? Chữ chạy trên thanh title của trình duyệt hay là trên thanh status? Nếu là title thì đây là đoạn code của nó: Mã: var pos=0; var str="Chuỗi muốn chạy trên thanh tiêu đề của trình duyệt"; // npos is used for forward scrolling var npos=str.length; // Normal upDate(). Other options upDateFW() and upDateWD() setInterval("upDate()",300); // Normal Scroll function upDate() { // Reset the title starting at pos document.title=str.substring(pos,str.length)+str.substring(0,pos); if(pos < str.length) pos++; else pos = 0; } // Scroll forward function upDateFW() { // Reset the title starting at pos document.title=str.substring(npos,str.length)+str.substring(0,npos); if(npos > 0) npos--; else npos = str.length; } // Scroll With Delay var delay = 20; function upDateWD() { if(pos < str.length) { document.title=str.substring(pos,str.length)+str.substring(0,pos); } else { if(pos > str.length+delay) { pos = 0; } } pos++; } Còn đây là trên thanh status: Mã: var Message="Welcome to my site"; var place=1; function scrollIn() { window.status=Message.substring(0, place); if (place >= Message.length) { place=1; window.setTimeout("scrollOut()",300); } else { place++; window.setTimeout("scrollIn()",50); } } function scrollOut() { window.status=Message.substring(place, Message.length); if (place >= Message.length) { place=1; window.setTimeout("scrollIn()", 100); } else { place++; window.setTimeout("scrollOut()", 50); } }
Để giữa 2 tag <script language="javascript"> và </script> Bạn chỉ cần thay đổi giá trị ở: Mã: var str="Chuỗi muốn chạy trên thanh tiêu đề của trình duyệt"; thành chuỗi tương ứng để hiển thị tiêu đề web là được rồi. VD: Mã: var str="Welcome to my site"; Còn về chữ trên thanh status thì cũng tương tự vậy. Nhưng nếu dùng script của cái status thì ở tag body bạn thêm vào onLoad="scrollIn();". VD: Mã: <html> <head> <script language="javascript"> <!-- var Message="Welcome to my site"; var place=1; function scrollIn() { window.status=Message.substring(0, place); if (place >= Message.length) { place=1; window.setTimeout("scrollOut()",300); } else { place++; window.setTimeout("scrollIn()",50); } } function scrollOut() { window.status=Message.substring(place, Message.length); if (place >= Message.length) { place=1; window.setTimeout("scrollIn()", 100); } else { place++; window.setTimeout("scrollOut()", 50); } } //--> </script> ... </head> <body onLoad="scrollIn();"> ... </body> </html>
Bạn muốn nói dòng chữ cuộn ở đầu trang phải không? Vào đây để biết thêm chi tiết Nếu muốn thay đổi tốc độ thì chỉ việc thêm vào thuộc tính scrollDelay. VD: Mã: <marquee scrollDelay="50">Welcome!!!</marquee> Bạn có thể thay đổi chiều rộng, chiều cao của marquee bằng cách thêm thuộc tính width và height