2019-02-25 课堂练习3

2019-02-25  本文已影响0人  youthisY

以下为 给出的原始链接 进行改动 创建外部链接

···
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta charset="utf-8" />
<title>随机抽题系统</title>
<style type="text/css">
*{margin:0;padding:0;list-style-type:none;}
a,img{border:0;}
body{font:12px/180% "Microsoft YaHei","微软雅黑", "宋体";}

    #bodybj{background:url(images.jpg) no-repeat center top;}
    #box{margin:auto;width:660px;font-size:66px;height:94px;line-height:94px;overflow:hidden;color:#138eee;text-align:center;padding:0 30px;margin-top:200px;}
    #bt{margin:auto;width:200px;text-align:center;margin-top:75px;color:#fff;font-size:25px;line-height:28px;cursor:pointer;}
    </style>
    
    <script type="text/javascript">
    var namelist=[
    "1号球","2号球","3号球","4号球","5号球","6号球","7号球","8号球","9号球","10号球"];
    var mytime=null;
    
    function doit(){
        var bt=window.document.getElementById("bt");
        if(mytime==null){
            bt.innerHTML="停止抽奖";
            show();                    
        }else{
            bt.innerHTML="开始抽奖";
            clearTimeout(mytime);
            mytime=null;                    
        }
    }
    
    function show(){
        var box=window.document.getElementById("box");
        var num=Math.floor((Math.random()*100000))%namelist.length;
        box.innerHTML=namelist[num];
        mytime=setTimeout("show()",1);
    } 
    </script>
</head>
<body id="bodybj">
    <div id="box">准备好了,开始抽奖了</div>
    <div id="bt" onClick="doit()">开始抽奖</div>
    
    <div style="text-align:center;margin:50px 0; font:normal 14px/24px 'MicroSoft YaHei';">
    <p>适用浏览器:IE8、360、FireFox、Chrome、Safari、Opera、傲游、搜狗、世界之窗. </p>
    
    </div>
</body>

</html>



把              script    标签中的东西    复制      
不要复制了    这个标签名       
![](https://img.haomeiwen.com/i12642951/1e5bbc10bd4353ca.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)
li'de
里的东西复制到另一个html里就行了
EG:
var namelist=[
        "1号球","2号球","3号球","4号球","5号球","6号球","7号球","8号球","9号球","10号球"];
        var mytime=null;
        
        function doit(){
            var bt=window.document.getElementById("bt");
            if(mytime==null){
                bt.innerHTML="停止抽奖";
                show();                    
            }else{
                bt.innerHTML="开始抽奖";
                clearTimeout(mytime);
                mytime=null;                    
            }
        }
        
        function show(){
            var box=window.document.getElementById("box");
            var num=Math.floor((Math.random()*100000))%namelist.length;
            box.innerHTML=namelist[num];
            mytime=setTimeout("show()",1);
        } // JavaScript Document



然后    创建外部链接    连接到 上述html

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>无标题文档</title>
<script type="text/javascript" src="789.js"></script>
</head>

<body>
</body>
</html>
上一篇下一篇

猜你喜欢

热点阅读