Home > Web Front-end > JS Tutorial > body text

js typing special effects code sharing

小云云
Release: 2018-03-02 13:12:11
Original
1325 people have browsed it

This article mainly shares with you the js typing special effects code, hoping to help everyone.



    ##
    <html>  
    <head>  
    <title>打字效果的带链接的新闻标题</title>  
    <meta http-equiv="Content-Type" content="text/html; charset=gb2312">  
    <style type="text/css">  
    body{font-size:14px;font-weight:bold;}  
    </style>  
    </head>  
    <body>  
    最新内容:<a id="HotNews" href="" target="_blank"></a>  
    <script>  
    var NewsTime = 2000;    //每条新闻的停留时间  
    var TextTime = 50;      //新闻标题文字出现等待时间,越小越快  
    var newsi = 0;  
    var txti = 0;  
    var txttimer;  
    var newstimer;  
    var newstitle = new Array();    //新闻标题  
    var newshref = new Array();     //新闻链接  
    newstitle[0] = "Jensen_Yao的博客";  
    newshref[0] = "http://blog.csdn.net/jensen_yao";  
    newstitle[1] = "http://blog.csdn.net/jensen_yao";  
    newshref[1] = "http://blog.csdn.net/jensen_yao";  
    newstitle[2] = "最高的效率就是对现有材料的最佳利用。";  
    newshref[2] = "http://blog.csdn.net/jensen_yao";  
    newstitle[3] = "学会偷懒!";  
    newshref[3] = "http://blog.csdn.net/jensen_yao";  
    newstitle[4] = "hello!";  
    newshref[4] = "http://blog.csdn.net/jensen_yao";  
    function shownew()  
    {  
      var endstr = "_";  
      hwnewstr = newstitle[newsi];  
      newslink = newshref[newsi];  
      if(txti==(hwnewstr.length-1)){endstr="";}  
      if(txti>=hwnewstr.length){  
        clearInterval(txttimer);  
        clearInterval(newstimer);  
        newsi++;  
        if(newsi>=newstitle.length){  
          newsi = 0  
        }  
        newstimer = setInterval("shownew()",NewsTime);  
        txti = 0;  
        return;  
       }  
       clearInterval(txttimer);  
       document.getElementById("HotNews").href=newslink;  
       document.getElementById("HotNews").innerHTML = hwnewstr.substring(0,txti+1)+endstr;  
       txti++;  
       txttimer = setInterval("shownew()",TextTime);  
     }  
    shownew();  
    </script>  
    <p><a href="http://www.108js.com" target="_blank">Jensen_Yao的博客</a></p>  
    </body>  
    </html>
    Copy after login
Related Recommended:

javascript to realize automatic text output (typing special effects)_javascript skills

The above is the detailed content of js typing special effects code sharing. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!