Java学习者论坛

 找回密码
 立即注册

QQ登录

只需一步,快速开始

手机号码,快捷登录

恭喜Java学习者论坛(https://www.javaxxz.com)已经为数万Java学习者服务超过8年了!积累会员资料超过10000G+
成为本站VIP会员,下载本站10000G+会员资源,购买链接:点击进入购买VIP会员
JAVA高级面试进阶视频教程Java架构师系统进阶VIP课程

分布式高可用全栈开发微服务教程

Go语言视频零基础入门到精通

Java架构师3期(课件+源码)

Java开发全终端实战租房项目视频教程

SpringBoot2.X入门到高级使用教程

大数据培训第六期全套视频教程

深度学习(CNN RNN GAN)算法原理

Java亿级流量电商系统视频教程

互联网架构师视频教程

年薪50万Spark2.0从入门到精通

年薪50万!人工智能学习路线教程

年薪50万!大数据从入门到精通学习路线年薪50万!机器学习入门到精通视频教程
仿小米商城类app和小程序视频教程深度学习数据分析基础到实战最新黑马javaEE2.1就业课程从 0到JVM实战高手教程 MySQL入门到精通教程
查看: 1174|回复: 0

^练习打字js □

[复制链接]

该用户从未签到

发表于 2011-11-1 12:11:32 | 显示全部楼层 |阅读模式
    一个练习打字程序,不兼rongfirefox,原因是自动获得焦点和截获键盘事件不兼容。

    HTML代码
   

   
   
    <html>  
    <head>  
    <title> 打字練习 </title>  
    <script>  
    var timer_handle;   
    var1 started=0;   

    function creatword()   
    {   
    var random_word=["A","B","C","D","E","F","G","H","I","J","K","L","M","N",   
        "O",&quot","Q","R","S","T","U","V","W","X","Z"];   
    var index=Math.floor(Math.random()*26);   
    document.word.fallword.value="  "+random_word[index]+"  ";   
    }   

    function fallgo()   
    {   
    var height=0;   
    height=document.word.fallword.style.top.slice(20,-2);   
    heightheight=height-1+21;   
    if(height>=680)   
    {   
    alert("you loose!");   
    clearInterval(timer_handle);   
    started=0;   
    document.word.fallword.style.top="30px";   
    document.word.fallword.value="ready";   
    }   
    else   
    {   
    document.word.fallword.style.top=height+"px";   
    }   
    }   

    function shot()   
    {   
    if(event.keyCode==13)   
    {   
    event.keyCode=9;   
    if("  "+document.word.inputword.value.toUpperCase()+"  "==document.word.fallword.value)   
    {   
    document.word.fallword.style.top="30px";   
    creatword();   
    document.word.inputword.value="";   
    }   
    }   
    }   

    function startfall()   
    {   
    if(started==0)   
    {   
    timer_handle=setInterval("fallgo();",500);   
    creatword();   
    started=1;   
    }   
    }   

    function fff()   
    {   
    document.word.inputword.focus();   
    }   
    </script>  
    </head>  

    <body>  
    <form name="word">  
    <input type="text" name="inputword" style="position:absolute;left:550px;top:700px" onkeydown="shot()" onblur="fff();">  
    <input type="button" name="fallword" value="ready" style="position:absolute;left:550px;top:30px"/>  
    <input type="button" name="start" value=" 开始 " style="position:absolute;left:600px;top:750px" onclick="startfall();"/>  
    </form>  
    </body>  
    </html>  

    <html>
    <head>
    <title> 打字练习 </title>
    <script>
        var timer_handle;
        var started=0;
        function creatword()
        {
            var random_word=["A","B","C","D","E","F","G","H","I","J","K","L","M","N",
                             "O","P","Q","R","S","T","U","V","W","X","Z"];
            var index=Math.floor(Math.random()*26);
            document.word.fallword.value="  "+random_word[index]+"  ";
        }
        function fallgo()
        {
            var height=0;
            height=document.word.fallword.style.top.slice(0,-2);
            height=height-1+21;
            if(height>=680)
            {
                alert("you loose!");
                clearInterval(timer_handle);
                started=0;
                document.word.fallword.style.top="30px";
                document.word.fallword.value="ready";
            }
            else
            {
                document.word.fallword.style.top=height+"px";
            }
        }
        function shot()
        {
            if(event.keyCode==13)
            {
                event.keyCode=9;
                if("  "+document.word.inputword.value.toUpperCase()+"  "==document.word.fallword.value)
                {
                    document.word.fallword.style.top="30px";
                    creatword();
                    document.word.inputword.value="";
                }
            }
        }
        function startfall()
        {
            if(started==0)
            {
                timer_handle=setInterval("fallgo();",500);
                creatword();
                started=1;
            }
        }
        function fff()
        {
            document.word.inputword.focus();
        }
    </script>
    </head>
    <body>
        <form name="word">
            <input type="text" name="inputword" style="position:absolute;left:550px;top:700px" onkeydown="shot()" onblur="fff();">
            <input type="button" name="fallword" value="ready" style="position:absolute;left:550px;top:30px"/>
            <input type="button" name="start" value=" 开始 " style="position:absolute;left:600px;top:750px" onclick="startfall();"/>
        </form>
    </body>
    </html>
欢迎来到Javaxue習者论壇,转載请注明地址:http://www.javaxxz.com.
回复

使用道具 举报

该用户从未签到

发表于 2011-11-1 12:11:39 | 显示全部楼层

Re:^练习打字js

不够完美,需要改进
回复 支持 反对

使用道具 举报

该用户从未签到

发表于 2011-11-1 12:11:46 | 显示全部楼层

Re:^练习打字js

少了一個字母“Y”
回复 支持 反对

使用道具 举报

该用户从未签到

发表于 2011-11-1 12:11:53 | 显示全部楼层

Re:^练习打字js

一般般。。。。。。
    与练习打字软件差太远,娛乐而已。
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

QQ|手机版|Java学习者论坛 ( 声明:本站资料整理自互联网,用于Java学习者交流学习使用,对资料版权不负任何法律责任,若有侵权请及时联系客服屏蔽删除 )

GMT+8, 2024-4-29 07:58 , Processed in 0.437936 second(s), 46 queries .

Powered by Discuz! X3.4

© 2001-2017 Comsenz Inc.

快速回复 返回顶部 返回列表