cần code chạy chữ ở thanh tiêu đề

Thảo luận trong 'Lập trình & Đồ hoạ' bắt đầu bởi boycodon2, 28/12/05.

  1. boycodon2

    boycodon2 Youtube Master Race

    Tham gia ngày:
    30/4/03
    Bài viết:
    90
    mình đang cần code chạy chữ thanh tiêu đề ai biết cho mình xin
     
  2. o0o Agumon o0o

    o0o Agumon o0o Donkey Kong

    Tham gia ngày:
    11/6/05
    Bài viết:
    351
    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);
       }
    }
     
  3. boycodon2

    boycodon2 Youtube Master Race

    Tham gia ngày:
    30/4/03
    Bài viết:
    90
    cảm ơn bạn nhiều nha! mình phải vào vọc mới được!
     
  4. boycodon2

    boycodon2 Youtube Master Race

    Tham gia ngày:
    30/4/03
    Bài viết:
    90
    ma` bạn ơi để trong code nào mới được vậy?
     
  5. SuperDiablos

    SuperDiablos Mr & Ms Pac-Man Lão Làng GVN

    Tham gia ngày:
    30/7/05
    Bài viết:
    246
    em cũng ko hiểu phải dùng code của bác Agumon như thế nào cả
    hướng dẫn chi tiết hơn được ko vậy
     
  6. boycodon2

    boycodon2 Youtube Master Race

    Tham gia ngày:
    30/4/03
    Bài viết:
    90
  7. o0o Agumon o0o

    o0o Agumon o0o Donkey Kong

    Tham gia ngày:
    11/6/05
    Bài viết:
    351
    Để 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>
    
     
  8. o0o Agumon o0o

    o0o Agumon o0o Donkey Kong

    Tham gia ngày:
    11/6/05
    Bài viết:
    351
    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
     

Chia sẻ trang này