Leisureeen

导航

JS生成随机数

    

随机数min代码和阅读代码如下:

 

<html>
    <head>
        <title>randValue</title>
        <meta name="viewport" content="width=device-width,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no"/>
        <script language="javascript">
            maxN=6;
            function show(){
                document.getElementById("msg").innerHTML=(msg.innerHTML=="?"?Math.ceil(Math.random()*maxN):"?");
            }
            function set(){
                maxN=parseInt(prompt("Please set the maximum value.","6"));
                if(isNaN(maxN)){
                    maxN=6;
                    alert("Wrong number,using 6 instead.");
                }
            }
        </script>
        <style type="text/css">
        .stbig {
            font-size: 128px;
            font-weight: bold;
        }
        </style>
    </head>
    <body bgcolor="FFCCFF"><br><br>
        <p align="center" class="stbig" id="msg" onClick="show()">?</p>
        <h1 align="center" onClick="set()">Setting</h1>
    </body>
</html>

 

随机验证码代码如下(len值可改):

 

posted on 2020-08-10 20:39  Leisureeen  阅读(167)  评论(0编辑  收藏  举报

JS